@propellerads/header 7.0.4 → 8.0.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
@@ -1,54 +1,100 @@
1
1
  # Header
2
2
 
3
- ![size](https://img.shields.io/bundlephobia/min/@propellerads/header.svg)
4
- ![](https://img.shields.io/npm/v/@propellerads/header.svg?style=flat-square)
3
+ The bar across the top of a cabinet: the brand on the left, the controls on
4
+ the right. Its dropdowns are shadcn's
5
+ [Popover](https://ui.shadcn.com/docs/components/base/popover) on
6
+ [Base UI](https://base-ui.com/react/components/popover), its tooltips are
7
+ [@propellerads/smart-tooltip](../SmartTooltip/README.md), and every colour,
8
+ gap, corner, shadow and duration comes from
9
+ [@propellerads/tokens](../Tokens/README.md).
5
10
 
6
- [NPM](https://www.npmjs.com/package/@propellerads/header) |
7
- [Github](https://github.com/propellerads/ui-components/tree/master/Components/Header)
11
+ ![](https://img.shields.io/npm/v/@propellerads/header.svg?style=flat-square)
8
12
 
9
13
  ## Installation
10
14
 
11
- - `bun add @propellerads/header` or `npm install @propellerads/header -S`
12
-
13
- ### How to use
15
+ ```sh
16
+ bun add @propellerads/header
17
+ ```
14
18
 
15
- - `import Header from '@propellerads/header';`
16
- - And render
19
+ The built entry imports its own stylesheet. The tokens are the app's:
17
20
 
21
+ ```ts
22
+ import '@propellerads/tokens/common.css';
23
+ import '@propellerads/tokens/propellerads.css'; // or monetag / propush / zeydoo
18
24
  ```
25
+
26
+ ## Use
27
+
28
+ ```tsx
29
+ import Header, {ThemeName} from '@propellerads/header';
30
+
19
31
  <Header
20
- theme={themes[theme]}
21
- logo={logo}
22
- sidebarButton={SidebarButton}
32
+ theme={ThemeName.Dark}
33
+ logo={<Logo />}
34
+ sidebarButton={<Header.Item aria-label="Menu" icon={<Burger />} onClick={toggleSidebar} />}
23
35
  >
24
- <Header.HeaderBalance
25
- balance={123456789.99}
26
- dailyEarned={newDailyEarned}
27
- />
28
-
29
- <Header.HeaderItem
30
- onClick={() => alert('Single notification has been shown')}
31
- component={customComponent}
32
- />
33
-
34
- <Header.HeaderDivider />
35
-
36
- <Header.HeaderItem icon={<Case size={SIZE.MEDIUM_SMALL} color={COLOR.GRAY}/>}>
37
- <Header.HeaderDropdown>
38
- {customDropDownContent}
39
- </Header.HeaderDropdown>
40
- </Header.HeaderItem>
41
-
42
- <Header.HeaderDivider />
43
-
44
- <Header.HeaderItem
45
- isRightDropdown
46
- title="Some text"
47
- icon={<User size={SIZE.MEDIUM_SMALL} color={COLOR.GRAY}/>}
48
- >
49
- <Header.HeaderDropdown>
50
- <Header.HeaderDropdownList items={userMenu} />
51
- </Header.HeaderDropdown>
52
- </Header.HeaderItem>
36
+ <Header.Balance balance={1234.5} dailyEarned={days} />
37
+
38
+ <Header.Item aria-label="Notifications" onClick={openNotifications} component={<Bell />} />
39
+
40
+ <Header.Divider />
41
+
42
+ <Header.Item isRightDropdown title="Account" icon={<User />}>
43
+ <Header.Dropdown id="user-menu">
44
+ <Header.DropdownList items={[<Link to="/profile">Profile</Link>, <button onClick={logout}>Log out</button>]} />
45
+ </Header.Dropdown>
46
+ </Header.Item>
47
+
48
+ <Header.Divider />
49
+ <Header.Time />
53
50
  </Header>
54
51
  ```
52
+
53
+ ## Parts
54
+
55
+ | Part | What it is |
56
+ | --- | --- |
57
+ | `Header` | The bar: fixed to the top, 56px, `id="header-container"` unless `id` says otherwise. |
58
+ | `Header.Item` | A control. With `onClick` it is a button; with `children` it opens them as a dropdown. |
59
+ | `Header.Dropdown` | The pad of a dropdown. Its `id` is where a product hangs its overrides. |
60
+ | `Header.DropdownList` | Rows of a menu. A link or a button in a row is stretched over the row. |
61
+ | `Header.Balance` | The balance, and a bar per day beside it with the day in a tooltip. |
62
+ | `Header.Time` | The time in EST, the date in a tooltip. |
63
+ | `Header.Divider` | A 20px rule between groups. |
64
+
65
+ Each part is also a named export: `HeaderItem`, `HeaderDropdown` and so on.
66
+
67
+ ## Dropdowns
68
+
69
+ - They open under their item, aligned to its left edge, or its right with
70
+ `isRightDropdown`. Below 769px they hang off the bar and span it.
71
+ - They take the focus when they open and give it back to the item when they
72
+ close. Escape and a press outside close them.
73
+ - A click anywhere inside closes them, as in v7. Content that has to stay open
74
+ — a form, a list that scrolls — stops the click's propagation.
75
+ - They are portalled to `<body>`, so a rule written against `#header-container
76
+ .something` no longer reaches them. A rule against the dropdown's own `id`
77
+ does.
78
+
79
+ ## Themes
80
+
81
+ | `theme` | What it is |
82
+ | --- | --- |
83
+ | `light` (default) | The page's surface and text; turns over with `data-theme` on `<html>`. |
84
+ | `dark` | Stays dark on a light page, dropdowns included. The balance is written in the text colour. |
85
+ | `transparent` | `light` without the surface and the shadow. |
86
+
87
+ ## Override points
88
+
89
+ | Custom property | Default |
90
+ | --- | --- |
91
+ | `--header-z-index` | `2001` |
92
+ | `--header-dropdown-z-index` | `2002` |
93
+
94
+ ## Motion
95
+
96
+ The dropdown arrives in `--duration-200` with `--ease-enter`, from 95% and four
97
+ pixels towards its item, and leaves in `--duration-100` with `--ease-exit` —
98
+ the step and the curve of the DatePicker panel, the Select menu and the
99
+ tooltip. Colours under the pointer move in `--duration-200` flat. With
100
+ `prefers-reduced-motion` the tokens cut every step to nothing.
package/dist/index.css ADDED
@@ -0,0 +1 @@
1
+ .header-theme--dark{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--color-light:#e6e6e6;--color-light-inversion:#212121;--color-dark-inversion:#f2f2f2;--color-quiet:#737373;--color-quiet-bg:#333;--color-quiet-text:#999;--color-formal:#262626;--color-rich:#4d4d4d;--over-fade:var(--color-light-inversion) 80%;--shadow-little:0 1px 0 #00000040, 0 1px 4px #0009;--shadow-middle:0 1px 1px #00000059, 0 2px 8px #0009;--shadow-big:0 0 3px #00000042, 0 4px 4px #00000059, 0 12px 16px #0009}.header{--header-accent:var(--color-action);box-sizing:border-box;z-index:var(--header-z-index,2001);background-color:var(--color-light-inversion);height:56px;box-shadow:var(--shadow-middle);color:var(--color-dark-inversion);font:var(--font-text);font-family:var(--font-family);justify-content:space-between;align-items:center;display:flex;position:fixed;inset:0 0 auto}.header.header-theme--dark{--header-accent:var(--color-dark-inversion)}.header.header-theme--transparent{box-shadow:none;background-color:#0000}.header__brand,.header__options{align-items:center;height:100%;display:flex}.header__item{align-items:center;height:100%;display:flex;position:relative}.header__item-button{box-sizing:border-box;height:100%;margin:var(--space-0);padding:var(--space-0) var(--space-16);color:var(--color-quiet-text);font:inherit;cursor:pointer;outline:var(--space-2) solid transparent;outline-offset:calc(-1 * var(--space-2));transition:color var(--duration-200) var(--ease-flat), outline-color var(--duration-200) var(--ease-flat);background:0 0;border:0;align-items:center;display:flex}.header__item-button>svg{transition:fill var(--duration-200) var(--ease-flat)}.header__item-button:hover,.header__item-button[data-popup-open]{color:var(--color-dark-inversion)}.header__item-button:hover>svg,.header__item-button[data-popup-open]>svg{fill:currentColor}.header__item-button:focus-visible{outline-color:var(--color-action)}.header__item-title{margin-inline-start:var(--space-4)}.header__divider{width:var(--space-1);background-color:var(--color-rich);height:20px}.header__time{padding:var(--space-0) var(--space-16);color:var(--color-quiet-text);cursor:default;display:flex}.header__balance{padding-block:var(--space-8);color:var(--header-accent);align-items:center;display:inline-flex}.header__balance-value{margin-inline:var(--space-8);font:var(--font-h4);font-family:var(--font-family);display:flex}.header__currency{color:var(--color-quiet-text);margin-inline-end:var(--space-4);font-weight:400}.header__chart{height:16px;cursor:default;align-items:stretch;margin-inline-end:var(--space-8);display:flex}.header__bar{box-sizing:border-box;width:7px;padding-inline:var(--space-1);position:relative}.header__bar-value{inset:auto var(--space-1) 0;background-color:var(--color-rich);transition:background-color var(--duration-200) var(--ease-flat);position:absolute}.header__bar:hover .header__bar-value,.header__bar[data-popup-open] .header__bar-value{background-color:var(--header-accent)}@media (width<=768px){.header__chart{display:none}}.header__positioner{z-index:var(--header-dropdown-z-index,2002)}.header__popup{--header-popup-shift:calc(-1 * var(--space-4));transform-origin:var(--transform-origin);transition:opacity var(--duration-200) var(--ease-enter), transform var(--duration-200) var(--ease-enter);outline:none}.header__popup[data-starting-style],.header__popup[data-ending-style]{opacity:0;transform:translateY(var(--header-popup-shift)) scale(.95)}.header__popup[data-ending-style]{transition-duration:var(--duration-100);transition-timing-function:var(--ease-exit)}.header__popup--wide{width:calc(var(--anchor-width) - 2 * var(--space-8))}.header__dropdown{box-sizing:border-box;min-width:150px;max-width:calc(100vw - 2 * var(--space-8));padding:var(--space-4);border-radius:var(--radius-8);background-color:var(--color-light-inversion);box-shadow:var(--shadow-middle), inset 0 0 0 var(--space-1) var(--color-rich);color:var(--color-dark-inversion);font:var(--font-text);font-family:var(--font-family)}.header__popup--wide .header__dropdown{width:100%;max-width:none}.header__menu-item{box-sizing:border-box;min-height:32px;padding:var(--space-4) var(--space-8);border-radius:var(--radius-4);cursor:pointer;text-align:start;transition:background-color var(--duration-200) var(--ease-flat);align-items:center;display:flex;position:relative}.header__menu-item:hover{background-color:color-mix(in srgb, var(--color-action) var(--opacity-tint), transparent)}.header__menu-item:has(:focus-visible){background-color:color-mix(in srgb, var(--color-action) var(--opacity-tint), transparent)}.header__menu-item.header__menu-item>*{box-sizing:border-box;width:100%;padding:inherit;border-radius:inherit;color:inherit;font:inherit;text-align:inherit;cursor:pointer;background:0 0;border:0;outline:none;align-items:center;margin:0;text-decoration:none;display:flex;position:absolute;inset:0}
package/dist/index.d.ts CHANGED
@@ -1,67 +1,122 @@
1
- import { FC, ReactNode } from 'react';
2
- import { CSSObject } from 'styled-components';
3
- import dayjs from 'dayjs';
4
- import { Theme } from '@propellerads/theme-annotation';
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Dayjs } from 'dayjs';
3
+ import { ReactNode, CSSProperties } from 'react';
5
4
 
5
+ /**
6
+ * What the bar is worn in.
7
+ *
8
+ * `light` is the page itself: the tokens' surface and text, so it turns over
9
+ * with the theme the product writes on <html>. `dark` stays dark on a light
10
+ * page as well — the dark theme's greys, scoped to the bar and its dropdowns.
11
+ * `transparent` is `light` with the surface and the shadow taken away, for a
12
+ * bar laid over a page that draws its own background.
13
+ */
14
+ declare const ThemeName: {
15
+ readonly Dark: "dark";
16
+ readonly Light: "light";
17
+ readonly Transparent: "transparent";
18
+ };
19
+ type ThemeName = (typeof ThemeName)[keyof typeof ThemeName];
20
+ type HeaderProps = {
21
+ /** The brand: a logo, a link home. */
22
+ logo: ReactNode;
23
+ /** Stands before the logo, usually an `Header.Item` that opens the sidebar. */
24
+ sidebarButton?: ReactNode;
25
+ /** The right-hand side: items, dividers, the balance, the time. */
26
+ children: ReactNode;
27
+ /** @default 'light' */
28
+ theme?: ThemeName;
29
+ /** @default 'header-container' — products find the bar by it. */
30
+ id?: string;
31
+ className?: string;
32
+ style?: CSSProperties;
33
+ /** @deprecated Use `style`. Kept for the products that still pass it. */
34
+ customHeaderStyle?: CSSProperties;
35
+ };
6
36
  type HeaderItemProps = {
37
+ /** Lands on the item's wrapper. */
7
38
  id?: string;
39
+ className?: string;
40
+ /**
41
+ * The dropdown, usually a `Header.Dropdown`. Clicking the item opens it,
42
+ * clicking anything inside it closes it. Ignored when `onClick` is given.
43
+ */
8
44
  children?: ReactNode;
45
+ /** Makes the item a plain button: no dropdown opens. */
9
46
  onClick?: () => void;
47
+ /** Free content of the button, after the icon and the title. */
10
48
  component?: ReactNode;
11
49
  icon?: ReactNode;
12
- isRightDropdown?: boolean;
13
50
  title?: string;
51
+ /** Aligns the dropdown to the item's right edge instead of its left. */
52
+ isRightDropdown?: boolean;
53
+ /** The button's accessible name, for an item that is only an icon. */
54
+ 'aria-label'?: string;
55
+ };
56
+ type HeaderDropdownProps = {
57
+ id?: string;
58
+ className?: string;
59
+ children: ReactNode;
60
+ };
61
+ type HeaderDropdownListProps = {
62
+ /** One row each. A link or a button in a row fills the whole row. */
63
+ items?: ReactNode[];
14
64
  };
15
- declare const HeaderItem: FC<HeaderItemProps>;
16
-
17
65
  type DayEarned = {
18
66
  date: string;
19
67
  value: number;
68
+ /** The bar's height, 0–100. Below 1 the bar is a hairline. */
20
69
  percentage: number;
21
70
  };
22
71
  type HeaderBalanceProps = {
23
72
  balance: number;
73
+ /** A bar per day beside the balance, hidden below the tablet breakpoint. */
24
74
  dailyEarned?: DayEarned[];
25
75
  };
26
- declare const HeaderBalance: FC<HeaderBalanceProps>;
27
-
28
76
  type HeaderTimeProps = {
29
- tooltipContent?: (ESTDate: dayjs.Dayjs) => string;
77
+ /** What the tooltip says, given the current time in EST. */
78
+ tooltipContent?: (ESTDate: Dayjs) => ReactNode;
30
79
  };
31
- declare const HeaderTime: FC<HeaderTimeProps>;
32
-
33
- declare const HeaderDivider: FC;
34
80
 
35
- type HeaderDropdownProps = {
36
- id?: string;
37
- children: ReactNode;
38
- };
39
- declare const HeaderDropdown: FC<HeaderDropdownProps>;
81
+ /**
82
+ * The balance and, beside it, a bar per day. Each bar names its day in a
83
+ * SmartTooltip; the tooltips share one provider with no delay, so running the
84
+ * pointer along the bars reads them one after another the way v7's labels did.
85
+ */
86
+ declare const HeaderBalance: ({ balance, dailyEarned }: HeaderBalanceProps) => react_jsx_runtime.JSX.Element;
40
87
 
41
- type HeaderDropdownListProps = {
42
- items?: ReactNode[];
43
- };
44
- declare const HeaderDropdownList: FC<HeaderDropdownListProps>;
45
-
46
- declare const ThemeName: {
47
- readonly Dark: "dark";
48
- readonly Light: "light";
49
- readonly Transparent: "transparent";
50
- };
51
- type ThemeName = (typeof ThemeName)[keyof typeof ThemeName];
52
- type HeaderTheme = Pick<Theme, 'header' | 'balance'>;
88
+ /**
89
+ * One control of the bar: a plain button with `onClick`, a dropdown trigger
90
+ * with `children`, or both missing — then it is a button that does nothing,
91
+ * which a product wraps to hang its own behaviour on (Beamer does).
92
+ *
93
+ * The dropdown is shadcn's Popover on Base UI: it stands under the item, takes
94
+ * the focus when it opens, gives it back to the item when it closes, and closes
95
+ * on Escape and on a press outside. A click anywhere inside it closes it too,
96
+ * as v7's did — a menu row has done its job once clicked. Content that has to
97
+ * stay open under a click stops the event's propagation, which works the same
98
+ * through the portal.
99
+ */
100
+ declare const HeaderItem: ({ id, className, children, onClick, component, icon, title, isRightDropdown, "aria-label": ariaLabel, }: HeaderItemProps) => react_jsx_runtime.JSX.Element;
101
+ /** The pad of a dropdown. Its `id` is where products hang their overrides. */
102
+ declare const HeaderDropdown: ({ id, className, children }: HeaderDropdownProps) => react_jsx_runtime.JSX.Element;
103
+ /** Rows of a menu: what is in a row fills it, so the whole row is the hit area. */
104
+ declare const HeaderDropdownList: ({ items }: HeaderDropdownListProps) => react_jsx_runtime.JSX.Element;
53
105
 
54
- declare const themes: Record<ThemeName, HeaderTheme>;
106
+ /** The system time, in EST, with the date in a tooltip. */
107
+ declare const HeaderTime: ({ tooltipContent }: HeaderTimeProps) => react_jsx_runtime.JSX.Element;
55
108
 
56
- type HeaderProps = {
57
- logo: ReactNode;
58
- customHeaderStyle?: CSSObject;
59
- sidebarButton?: ReactNode;
60
- children: ReactNode;
61
- theme?: HeaderTheme;
62
- id?: string;
63
- };
64
- type HeaderCompound = FC<HeaderProps> & {
109
+ /**
110
+ * v7 took a theme object and products wrote `theme={themes.dark}`. The object
111
+ * is a name now, and `themes` maps each name onto itself, so that line keeps
112
+ * working.
113
+ *
114
+ * @deprecated Pass `ThemeName.Dark` or `'dark'`.
115
+ */
116
+ declare const themes: Record<ThemeName, ThemeName>;
117
+ declare const HeaderDivider: () => react_jsx_runtime.JSX.Element;
118
+ declare const HeaderRoot: ({ logo, sidebarButton, children, theme, id, className, style, customHeaderStyle, }: HeaderProps) => react_jsx_runtime.JSX.Element;
119
+ type HeaderCompound = typeof HeaderRoot & {
65
120
  Item: typeof HeaderItem;
66
121
  Balance: typeof HeaderBalance;
67
122
  Time: typeof HeaderTime;
@@ -71,5 +126,5 @@ type HeaderCompound = FC<HeaderProps> & {
71
126
  };
72
127
  declare const Header: HeaderCompound;
73
128
 
74
- export { ThemeName, Header as default, themes };
75
- export type { HeaderProps };
129
+ export { Header, HeaderBalance, HeaderDivider, HeaderDropdown, HeaderDropdownList, HeaderItem, HeaderTime, ThemeName, Header as default, themes };
130
+ export type { DayEarned, HeaderBalanceProps, HeaderDropdownListProps, HeaderDropdownProps, HeaderItemProps, HeaderProps, HeaderTimeProps };
package/dist/index.js CHANGED
@@ -1,348 +1,163 @@
1
- import { useEffect as e, useRef as t, useState as n } from "react";
2
- import r, { ThemeContext as i } from "styled-components";
3
- import { actionColor as a, black as o, borderRadius as s, fontNormal as c, fontSmall as l, gray50 as u, gray70 as d, gray80 as f, gray95 as p, smallDevices as m, spacing as h, white as g } from "@propellerads/stylevariables";
4
- import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
5
- import b from "@propellerads/currency";
6
- import { Position as x, hideTooltip as S, showTooltip as C } from "@propellerads/smart-tooltip";
7
- import w from "dayjs";
8
- import ee from "dayjs/plugin/utc";
9
- //#region src/hooks/useClickOutside.ts
10
- var T = (t, n) => {
11
- e(() => {
12
- let e = (e) => {
13
- let r = t.current;
14
- !r || r.contains(e.target) || n(e);
15
- };
16
- return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e), () => {
17
- document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e);
18
- };
19
- }, [t, n]);
20
- }, E = r.div`
21
- position: relative;
22
- display: flex;
23
- height: 100%;
24
- align-items: center;
25
- `, D = r.button`
26
- background: transparent;
27
- border: 0;
28
- margin: 0;
29
- outline: none;
30
- font-size: ${c}px;
31
- display: flex;
32
- align-items: center;
33
- padding: 0 ${h * 4}px;
34
- height: 100%;
35
- cursor: pointer;
36
- color: ${(e) => e.theme.header?.menuItemColor};
37
-
38
- &:hover {
39
- color: ${(e) => e.theme.header?.menuItemColorHover};
40
-
41
- & > svg {
42
- fill: ${(e) => e.theme.header?.menuItemColorHover};
43
- }
44
- }
45
- `, O = r.div`
46
- margin-left: ${h}px;
47
- `, k = r.div`
48
- z-index: 99;
49
- padding: ${h}px;
50
- position: fixed;
51
- left: 0 !important;
52
- top: 56px;
53
- right: 0 !important;
54
-
55
- ${(e) => e.$isRightDropdown && `
56
- left: ${e.$isRightDropdown ? "initial" : 0};
57
- right: ${e.$isRightDropdown ? 0 : "initial"};
58
- `};
59
-
60
- @media (min-width: ${m}px) {
61
- width: initial;
62
- position: absolute;
63
- top: 100%;
64
- left: initial !important;
65
- }
66
- `, A = ({ id: e, children: r, isRightDropdown: i = !1, icon: a, title: o, onClick: s, component: c }) => {
67
- let l = t(null), [u, d] = n(!1), f = o && /* @__PURE__ */ v(O, { children: o });
68
- return T(l, () => d(!1)), /* @__PURE__ */ y(E, {
1
+ import { createContext as e, useContext as t, useEffect as n, useMemo as r, useRef as i, useState as a, useSyncExternalStore as o } from "react";
2
+ import { Position as s, Tooltip as c, TooltipContent as l, TooltipProvider as u, TooltipTrigger as d } from "@propellerads/smart-tooltip";
3
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
4
+ import { clsx as h } from "clsx";
5
+ import { Popover as g } from "@base-ui-components/react/popover";
6
+ import _ from "dayjs";
7
+ import v from "dayjs/plugin/utc";
8
+ import './index.css';//#region src/balance.tsx
9
+ var y = (e, t = 2) => e.toFixed(t).replace(/(\d)(?=(\d{3})+\.)/g, "$1,"), b = ({ value: e, decimals: t }) => /* @__PURE__ */ m("span", { children: [/* @__PURE__ */ p("span", {
10
+ className: "header__currency",
11
+ children: "$"
12
+ }), y(e, t)] }), x = ({ day: e }) => /* @__PURE__ */ m(c, { children: [/* @__PURE__ */ p(d, {
13
+ render: /* @__PURE__ */ p("span", {}),
14
+ className: "header__bar",
15
+ children: /* @__PURE__ */ p("span", {
16
+ className: "header__bar-value",
17
+ style: { height: e.percentage > 1 ? `${e.percentage}%` : "1px" }
18
+ })
19
+ }), /* @__PURE__ */ m(l, {
20
+ side: s.Bottom,
21
+ children: [
22
+ e.date,
23
+ " — ",
24
+ /* @__PURE__ */ p(b, { value: e.value })
25
+ ]
26
+ })] }), S = ({ balance: e, dailyEarned: t = [] }) => /* @__PURE__ */ m("div", {
27
+ className: "header__balance",
28
+ children: [/* @__PURE__ */ p("span", {
29
+ className: "header__balance-value",
30
+ children: /* @__PURE__ */ p(b, { value: e })
31
+ }), t.length > 0 && /* @__PURE__ */ p(u, {
32
+ delay: 0,
33
+ closeDelay: 0,
34
+ children: /* @__PURE__ */ p("span", {
35
+ className: "header__chart",
36
+ children: t.map((e, t) => /* @__PURE__ */ p(x, { day: e }, t))
37
+ })
38
+ })]
39
+ }), C = (...e) => h(e), w = e(null), T = () => t(w), E = "(max-width: 768px)", D = (e) => {
40
+ let t = window.matchMedia(E);
41
+ return t.addEventListener("change", e), () => t.removeEventListener("change", e);
42
+ }, O = () => o(D, () => window.matchMedia(E).matches, () => !1), k = ({ icon: e, title: t, component: n }) => /* @__PURE__ */ m(f, { children: [
43
+ e,
44
+ t !== void 0 && /* @__PURE__ */ p("span", {
45
+ className: "header__item-title",
46
+ children: t
47
+ }),
48
+ n
49
+ ] }), A = ({ id: e, className: t, children: n, onClick: r, component: i, icon: o, title: s, isRightDropdown: c = !1, "aria-label": l }) => {
50
+ let u = T(), d = O(), [f, h] = a(!1), _ = /* @__PURE__ */ p(k, {
51
+ icon: o,
52
+ title: s,
53
+ component: i
54
+ });
55
+ return n != null && r === void 0 ? /* @__PURE__ */ p("div", {
69
56
  id: e,
70
- ref: l,
71
- children: [/* @__PURE__ */ y(D, {
72
- onClick: () => {
73
- if (s) {
74
- s();
75
- return;
76
- }
77
- d((e) => !e);
78
- },
79
- children: [
80
- a,
81
- f,
82
- c
83
- ]
84
- }), r && u && /* @__PURE__ */ v(k, {
85
- $isRightDropdown: i,
86
- onClick: () => d(!1),
87
- children: r
88
- })]
57
+ className: C("header__item", t),
58
+ children: /* @__PURE__ */ m(g.Root, {
59
+ open: f,
60
+ onOpenChange: h,
61
+ children: [/* @__PURE__ */ p(g.Trigger, {
62
+ className: "header__item-button",
63
+ "aria-label": l,
64
+ children: _
65
+ }), /* @__PURE__ */ p(g.Portal, { children: /* @__PURE__ */ p(g.Positioner, {
66
+ className: C("header__positioner", `header-theme--${u?.theme ?? "light"}`),
67
+ anchor: d ? u?.barRef : void 0,
68
+ side: "bottom",
69
+ align: c || d ? "end" : "start",
70
+ sideOffset: d ? 0 : 4,
71
+ collisionPadding: 8,
72
+ children: /* @__PURE__ */ p(g.Popup, {
73
+ className: C("header__popup", d && "header__popup--wide"),
74
+ onClick: () => h(!1),
75
+ children: n
76
+ })
77
+ }) })]
78
+ })
79
+ }) : /* @__PURE__ */ p("div", {
80
+ id: e,
81
+ className: C("header__item", t),
82
+ children: /* @__PURE__ */ p("button", {
83
+ type: "button",
84
+ className: "header__item-button",
85
+ "aria-label": l,
86
+ onClick: r,
87
+ children: _
88
+ })
89
89
  });
90
- }, j = r.div`
91
- display: inline-flex;
92
- align-items: center;
93
- padding: ${h * 2}px 0;
94
- z-index: 1;
95
- color: ${(e) => e.theme.balance?.textColor};
96
- background-color: ${(e) => e.theme.header?.backgroundColor};
97
- `, M = r.div`
98
- margin: 0 ${h * 2}px;
99
- line-height: 1.14;
100
- letter-spacing: 0.3px;
101
- font-size: ${c}px;
102
- display: flex;
103
- font-weight: bold;
104
- color: ${(e) => e.theme.balance?.textColor};
105
- `, N = r.div`
106
- margin-right: 8px;
107
- position: relative;
108
- display: flex;
109
- align-items: stretch;
110
- width: 49px;
111
- flex: 0 0 49px;
112
- height: 16px;
113
- cursor: default;
114
-
115
- @media (max-width: ${m}px) {
116
- display: none;
117
- }
118
- `, P = r.span`
119
- opacity: 0;
120
- position: absolute;
121
- top: calc(-100% - 2px);
122
- left: 0;
123
- display: block;
124
- padding: 0 3px;
125
- font-size: ${l}px;
126
- line-height: 16px;
127
- border-radius: ${s}px;
128
- white-space: nowrap;
129
- pointer-events: none;
130
- color: ${(e) => e.theme.balance?.chartColor};
131
- background-color: ${(e) => e.theme.balance?.chartBackgroundColor};
132
- `, F = r.div`
133
- position: relative;
134
- flex: 0 0 7px;
135
- border: solid transparent;
136
- border-width: 0 1px;
137
- opacity: 0.3;
138
-
139
- &:hover {
140
- opacity: 1;
141
- ${P} {
142
- opacity: 1;
143
- }
144
- }
145
- `, I = r.div`
146
- position: absolute;
147
- left: 0;
148
- bottom: 0;
149
- right: 0;
150
- height: ${(e) => e.$percentage > 1 ? `${e.$percentage}%` : "1px"};
151
- background-color: ${(e) => e.theme.balance?.dailyEarnedColor};
152
- `, L = ({ day: e }) => {
153
- let { date: t, value: n, percentage: r } = e;
154
- return /* @__PURE__ */ y(F, { children: [/* @__PURE__ */ v(I, { $percentage: r }), /* @__PURE__ */ y(P, { children: [
155
- t,
156
- " - ",
157
- /* @__PURE__ */ v(b, { value: n })
158
- ] })] });
159
- }, R = ({ balance: e, dailyEarned: t = [] }) => {
160
- let n = !!t.length;
161
- return /* @__PURE__ */ y(j, { children: [/* @__PURE__ */ v(M, { children: /* @__PURE__ */ v(b, {
162
- value: e,
163
- decimalPosition: 2
164
- }) }), n && /* @__PURE__ */ v(N, { children: t.map((e, t) => /* @__PURE__ */ v(L, { day: e }, t)) })] });
165
- }, z = r.div`
166
- display: flex;
167
- padding: 0 ${h * 4}px;
168
- cursor: default;
169
- color: ${(e) => e.theme.header?.menuItemColor};
170
- `;
90
+ }, j = ({ id: e, className: t, children: n }) => /* @__PURE__ */ p("div", {
91
+ id: e,
92
+ className: C("header__dropdown", t),
93
+ children: n
94
+ }), M = ({ items: e = [] }) => /* @__PURE__ */ p("div", {
95
+ className: "header__menu",
96
+ children: e.map((e, t) => /* @__PURE__ */ p("div", {
97
+ className: "header__menu-item",
98
+ children: e
99
+ }, t))
100
+ });
171
101
  //#endregion
172
- //#region src/HeaderTime/index.tsx
173
- w.extend(ee);
174
- var B = () => w.utc().subtract(5, "hour"), V = ({ tooltipContent: t = (e) => `System time: ${e.format("HH:mm DD.MM")} (EST)` }) => {
175
- let [r, i] = n(B());
176
- return e(() => {
177
- let e = setInterval(() => {
178
- i(B());
179
- }, 1e3);
102
+ //#region src/time.tsx
103
+ _.extend(v);
104
+ var N = () => _.utc().subtract(5, "hour"), P = (e) => `System time: ${e.format("HH:mm DD.MM")} (EST)`, F = ({ tooltipContent: e = P }) => {
105
+ let [t, r] = a(N);
106
+ return n(() => {
107
+ let e = setInterval(() => r(N()), 1e3);
180
108
  return () => clearInterval(e);
181
- }, []), /* @__PURE__ */ v(z, {
182
- onMouseEnter: (e) => {
183
- C(e.currentTarget, t(r), x.Bottom);
184
- },
185
- onMouseLeave: S,
186
- children: `${r.format("HH:mm")} EST`
187
- });
188
- }, H = r.div`
189
- width: 1px;
190
- height: 20px;
191
- background-color: ${(e) => e.theme.header?.dividerColor};
192
- `, U = () => /* @__PURE__ */ v(H, {}), W = r.div`
193
- border-radius: ${s}px;
194
- box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);
195
- padding: ${h * 2}px 0;
196
- width: 100%;
197
- background-color: ${(e) => e.theme.header?.menuItemBackgroundColor};
198
-
199
- @media (min-width: ${m}px) {
200
- width: auto;
201
- min-width: 150px;
202
- }
203
- `, G = ({ id: e, children: t }) => /* @__PURE__ */ v(W, {
204
- id: e,
205
- children: t
206
- }), K = r.div`
207
- height: 48px;
208
- padding: 0 16px;
209
- position: relative;
210
- display: flex;
211
- align-items: center;
212
- cursor: pointer;
213
- text-align: left;
214
- background-color: ${(e) => e.theme.header?.menuItemBackgroundColor};
215
- color: ${(e) => e.theme.header?.menuItemColor};
216
-
217
- &:hover {
218
- background-color: ${(e) => e.theme.header?.menuItemBackgroundColorHover};
219
- color: ${(e) => e.theme.header?.menuItemColorHover};
220
- }
221
-
222
- & > * {
223
- border: 0;
224
- margin: 0;
225
- color: inherit !important;
226
- position: absolute;
227
- left: 0;
228
- top: 0;
229
- right: 0;
230
- bottom: 0;
231
- width: 100%;
232
- display: flex;
233
- align-items: center;
234
- padding: 0 ${h * 4}px;
235
- outline: none;
236
- font-size: inherit;
237
- background: transparent;
238
- transition: color 200ms ease-out;
239
- text-decoration: none;
240
- }
241
- `, q = ({ item: e }) => /* @__PURE__ */ v(K, { children: e }), J = ({ items: e = [] }) => /* @__PURE__ */ v(_, { children: e.map((e, t) => /* @__PURE__ */ v(q, { item: e }, t)) }), Y = r.div`
242
- display: flex;
243
- height: 56px;
244
- align-items: center;
245
- justify-content: space-between;
246
- position: fixed;
247
- top: 0;
248
- left: 0;
249
- right: 0;
250
- z-index: 2001;
251
- background-color: ${(e) => e.theme?.header?.backgroundColor};
252
- box-shadow: ${(e) => e.theme?.header?.boxShadow};
253
-
254
- ${(e) => e.$customHeaderStyle}
255
- `, X = r.div`
256
- display: flex;
257
- align-items: center;
258
- `, Z = r.div`
259
- display: flex;
260
- align-items: center;
261
- height: 100%;
262
- `, Q = {
109
+ }, []), /* @__PURE__ */ m(c, { children: [/* @__PURE__ */ p(d, {
110
+ render: /* @__PURE__ */ p("span", {}),
111
+ className: "header__time",
112
+ children: `${t.format("HH:mm")} EST`
113
+ }), /* @__PURE__ */ p(l, {
114
+ side: s.Bottom,
115
+ children: e(t)
116
+ })] });
117
+ }, I = {
263
118
  Dark: "dark",
264
119
  Light: "light",
265
120
  Transparent: "transparent"
266
- }, $ = {
267
- [Q.Dark]: {
268
- header: {
269
- backgroundColor: "hsl(228, 16.9%, 17.5%)",
270
- color: d,
271
- colorHover: g,
272
- boxShadow: "0 2px 8px 0 hsla(0, 0%, 0%, 0.1)",
273
- dividerColor: u,
274
- menuItemColor: d,
275
- menuItemColorHover: g,
276
- menuItemBackgroundColor: "hsl(228, 16.9%, 17.5%)",
277
- menuItemBackgroundColorHover: "hsla(0, 0%, 0%, 0.3)"
278
- },
279
- balance: {
280
- borderColor: f,
281
- textColor: g,
282
- dailyEarnedColor: g,
283
- chartColor: o,
284
- chartBackgroundColor: g
285
- }
286
- },
287
- [Q.Light]: {
288
- header: {
289
- backgroundColor: g,
290
- color: d,
291
- colorHover: o,
292
- boxShadow: "0 2px 8px 0 hsla(0, 0%, 0%, 0.1)",
293
- dividerColor: p,
294
- menuItemColor: d,
295
- menuItemColorHover: o,
296
- menuItemBackgroundColor: g,
297
- menuItemBackgroundColorHover: p
298
- },
299
- balance: {
300
- borderColor: f,
301
- textColor: a,
302
- dailyEarnedColor: a,
303
- chartColor: g,
304
- chartBackgroundColor: o
305
- }
306
- },
307
- [Q.Transparent]: {
308
- header: {
309
- backgroundColor: "none",
310
- color: d,
311
- colorHover: o,
312
- dividerColor: u,
313
- menuItemColor: d,
314
- menuItemColorHover: g,
315
- menuItemBackgroundColor: "hsl(228, 16.9%, 17.5%)",
316
- menuItemBackgroundColorHover: "hsla(0, 0%, 0%, 0.3)",
317
- boxShadow: "none"
318
- },
319
- balance: {
320
- borderColor: f,
321
- textColor: a,
322
- dailyEarnedColor: a,
323
- chartColor: g,
324
- chartBackgroundColor: o
325
- }
326
- }
327
- }, te = ({ theme: e = $.light, children: t }) => /* @__PURE__ */ v(i.Provider, {
328
- value: e,
329
- children: t
330
- }), ne = Object.assign(({ logo: e, customHeaderStyle: t = {}, sidebarButton: n, children: r, theme: i, id: a = "header-container" }) => /* @__PURE__ */ v(te, {
331
- ...i ? { theme: i } : {},
332
- children: /* @__PURE__ */ y(Y, {
333
- id: a,
334
- $customHeaderStyle: t,
335
- children: [/* @__PURE__ */ y(X, { children: [n, e] }), /* @__PURE__ */ v(Z, { children: r })]
336
- })
337
- }), {
121
+ }, L = {
122
+ [I.Dark]: I.Dark,
123
+ [I.Light]: I.Light,
124
+ [I.Transparent]: I.Transparent
125
+ }, R = (e) => Object.values(I).includes(e) ? e : I.Light, z = () => /* @__PURE__ */ p("span", {
126
+ className: "header__divider",
127
+ "aria-hidden": "true"
128
+ }), B = Object.assign(({ logo: e, sidebarButton: t, children: n, theme: a, id: o = "header-container", className: s, style: c, customHeaderStyle: l }) => {
129
+ let u = i(null), d = R(a), f = r(() => ({
130
+ barRef: u,
131
+ theme: d
132
+ }), [d]);
133
+ return /* @__PURE__ */ p(w.Provider, {
134
+ value: f,
135
+ children: /* @__PURE__ */ m("header", {
136
+ ref: u,
137
+ id: o,
138
+ className: C("header", `header-theme--${d}`, s),
139
+ style: {
140
+ ...l,
141
+ ...c
142
+ },
143
+ children: [/* @__PURE__ */ m("div", {
144
+ className: "header__brand",
145
+ children: [t, e]
146
+ }), /* @__PURE__ */ p("div", {
147
+ className: "header__options",
148
+ children: n
149
+ })]
150
+ })
151
+ });
152
+ }, {
338
153
  Item: A,
339
- Balance: R,
340
- Time: V,
341
- Divider: U,
342
- Dropdown: G,
343
- DropdownList: J
154
+ Balance: S,
155
+ Time: F,
156
+ Divider: z,
157
+ Dropdown: j,
158
+ DropdownList: M
344
159
  });
345
160
  //#endregion
346
- export { Q as ThemeName, ne as default, $ as themes };
161
+ export { B as Header, B as default, S as HeaderBalance, z as HeaderDivider, j as HeaderDropdown, M as HeaderDropdownList, A as HeaderItem, F as HeaderTime, I as ThemeName, L as themes };
347
162
 
348
163
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/hooks/useClickOutside.ts","../src/HeaderItem/style.tsx","../src/HeaderItem/index.tsx","../src/HeaderBalance/style.tsx","../src/HeaderBalance/index.tsx","../src/HeaderTime/style.tsx","../src/HeaderTime/index.tsx","../src/HeaderDivider/style.tsx","../src/HeaderDivider/index.tsx","../src/HeaderDropdown/style.tsx","../src/HeaderDropdown/index.tsx","../src/HeaderDropdownList/style.tsx","../src/HeaderDropdownList/index.tsx","../src/style.tsx","../src/themes/types.ts","../src/themes/variables.ts","../src/themes/context.tsx","../src/index.tsx"],"sourcesContent":["import type {RefObject} from 'react';\nimport {useEffect} from 'react';\n\nexport const useOnClickOutside = <T extends HTMLElement>(\n ref: RefObject<T | null>,\n handler: (event: MouseEvent | TouchEvent) => void,\n): void => {\n useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n const el = ref.current;\n if (!el || el.contains(event.target as Node)) {\n return;\n }\n handler(event);\n };\n\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, handler]);\n};\n","import styled from 'styled-components';\nimport {spacing, smallDevices, fontNormal} from '@propellerads/stylevariables';\n\nconst StyledHeaderItem = styled.div`\n position: relative;\n display: flex;\n height: 100%;\n align-items: center;\n`;\n\nconst StyledHeaderItemButton = styled.button`\n background: transparent;\n border: 0;\n margin: 0;\n outline: none;\n font-size: ${fontNormal}px;\n display: flex;\n align-items: center;\n padding: 0 ${spacing * 4}px;\n height: 100%;\n cursor: pointer;\n color: ${(props) => props.theme.header?.menuItemColor};\n\n &:hover {\n color: ${(props) => props.theme.header?.menuItemColorHover};\n\n & > svg {\n fill: ${(props) => props.theme.header?.menuItemColorHover};\n }\n }\n`;\n\nconst StyledHeaderItemTitle = styled.div`\n margin-left: ${spacing}px;\n`;\n\ntype StyledHeaderItemDropdownProps = {\n $isRightDropdown: boolean;\n};\n\nconst StyledHeaderItemDropdown = styled.div<StyledHeaderItemDropdownProps>`\n z-index: 99;\n padding: ${spacing}px;\n position: fixed;\n left: 0 !important;\n top: 56px;\n right: 0 !important;\n\n ${(props) =>\n props.$isRightDropdown &&\n `\n left: ${props.$isRightDropdown ? 'initial' : 0};\n right: ${props.$isRightDropdown ? 0 : 'initial'};\n `};\n\n @media (min-width: ${smallDevices}px) {\n width: initial;\n position: absolute;\n top: 100%;\n left: initial !important;\n }\n`;\n\nexport {StyledHeaderItem, StyledHeaderItemTitle, StyledHeaderItemDropdown, StyledHeaderItemButton};\n","import type {FC, ReactNode} from 'react';\nimport {useRef, useState} from 'react';\nimport {useOnClickOutside} from '../hooks/useClickOutside';\nimport {StyledHeaderItem, StyledHeaderItemButton, StyledHeaderItemDropdown, StyledHeaderItemTitle} from './style';\n\ntype HeaderItemProps = {\n id?: string;\n children?: ReactNode;\n onClick?: () => void;\n component?: ReactNode;\n icon?: ReactNode;\n isRightDropdown?: boolean;\n title?: string;\n};\n\nconst HeaderItem: FC<HeaderItemProps> = ({id, children, isRightDropdown = false, icon, title, onClick, component}) => {\n const ref = useRef<HTMLDivElement | null>(null);\n const [isShowDropdown, setDropdown] = useState(false);\n\n const titleComponent = title && <StyledHeaderItemTitle>{title}</StyledHeaderItemTitle>;\n\n useOnClickOutside(ref, () => setDropdown(false));\n\n return (\n <StyledHeaderItem id={id} ref={ref}>\n <StyledHeaderItemButton\n onClick={() => {\n if (onClick) {\n onClick();\n return;\n }\n\n setDropdown((previousState) => !previousState);\n }}\n >\n {icon}\n {titleComponent}\n {component}\n </StyledHeaderItemButton>\n {children && isShowDropdown && (\n <StyledHeaderItemDropdown $isRightDropdown={isRightDropdown} onClick={() => setDropdown(false)}>\n {children}\n </StyledHeaderItemDropdown>\n )}\n </StyledHeaderItem>\n );\n};\n\nexport default HeaderItem;\n","import styled from 'styled-components';\nimport {spacing, smallDevices, borderRadius, fontNormal, fontSmall} from '@propellerads/stylevariables';\n\nconst StyledHeaderBalance = styled.div`\n display: inline-flex;\n align-items: center;\n padding: ${spacing * 2}px 0;\n z-index: 1;\n color: ${(props) => props.theme.balance?.textColor};\n background-color: ${(props) => props.theme.header?.backgroundColor};\n`;\n\nconst StyledHeaderBalanceValue = styled.div`\n margin: 0 ${spacing * 2}px;\n line-height: 1.14;\n letter-spacing: 0.3px;\n font-size: ${fontNormal}px;\n display: flex;\n font-weight: bold;\n color: ${(props) => props.theme.balance?.textColor};\n`;\nconst StyledHeaderBalanceDailyEarned = styled.div`\n margin-right: 8px;\n position: relative;\n display: flex;\n align-items: stretch;\n width: 49px;\n flex: 0 0 49px;\n height: 16px;\n cursor: default;\n\n @media (max-width: ${smallDevices}px) {\n display: none;\n }\n`;\n\nconst StyledHeaderBalanceChartDay = styled.span`\n opacity: 0;\n position: absolute;\n top: calc(-100% - 2px);\n left: 0;\n display: block;\n padding: 0 3px;\n font-size: ${fontSmall}px;\n line-height: 16px;\n border-radius: ${borderRadius}px;\n white-space: nowrap;\n pointer-events: none;\n color: ${(props) => props.theme.balance?.chartColor};\n background-color: ${(props) => props.theme.balance?.chartBackgroundColor};\n`;\n\nconst StyledHeaderBalanceChart = styled.div`\n position: relative;\n flex: 0 0 7px;\n border: solid transparent;\n border-width: 0 1px;\n opacity: 0.3;\n\n &:hover {\n opacity: 1;\n ${StyledHeaderBalanceChartDay} {\n opacity: 1;\n }\n }\n`;\n\ntype StyledHeaderBalanceChartValueProps = {\n $percentage: number;\n};\n\nconst StyledHeaderBalanceChartValue = styled.div<StyledHeaderBalanceChartValueProps>`\n position: absolute;\n left: 0;\n bottom: 0;\n right: 0;\n height: ${(props) => (props.$percentage > 1 ? `${props.$percentage}%` : '1px')};\n background-color: ${(props) => props.theme.balance?.dailyEarnedColor};\n`;\n\nexport {\n StyledHeaderBalance,\n StyledHeaderBalanceValue,\n StyledHeaderBalanceDailyEarned,\n StyledHeaderBalanceChart,\n StyledHeaderBalanceChartValue,\n StyledHeaderBalanceChartDay,\n};\n","import Currency from '@propellerads/currency';\nimport type {FC} from 'react';\nimport {\n StyledHeaderBalance,\n StyledHeaderBalanceChart,\n StyledHeaderBalanceChartDay,\n StyledHeaderBalanceChartValue,\n StyledHeaderBalanceDailyEarned,\n StyledHeaderBalanceValue,\n} from './style';\n\ntype DayEarned = {\n date: string;\n value: number;\n percentage: number;\n};\n\ntype HeaderBalanceChartProps = {\n day: DayEarned;\n};\n\nconst HeaderBalanceChart: FC<HeaderBalanceChartProps> = ({day}) => {\n const {date, value, percentage} = day;\n\n return (\n <StyledHeaderBalanceChart>\n <StyledHeaderBalanceChartValue $percentage={percentage} />\n <StyledHeaderBalanceChartDay>\n {date} - <Currency value={value} />\n </StyledHeaderBalanceChartDay>\n </StyledHeaderBalanceChart>\n );\n};\n\ntype HeaderBalanceProps = {\n balance: number;\n dailyEarned?: DayEarned[];\n};\n\nconst HeaderBalance: FC<HeaderBalanceProps> = ({balance, dailyEarned = []}) => {\n const dailyEarnedExist = Boolean(dailyEarned.length);\n\n return (\n <StyledHeaderBalance>\n <StyledHeaderBalanceValue>\n <Currency value={balance} decimalPosition={2} />\n </StyledHeaderBalanceValue>\n\n {dailyEarnedExist && (\n <StyledHeaderBalanceDailyEarned>\n {dailyEarned.map((day, idx) => (\n <HeaderBalanceChart key={idx} day={day} />\n ))}\n </StyledHeaderBalanceDailyEarned>\n )}\n </StyledHeaderBalance>\n );\n};\n\nexport default HeaderBalance;\n","import styled from 'styled-components';\nimport {spacing} from '@propellerads/stylevariables';\n\nexport const StyledHeaderTime = styled.div`\n display: flex;\n padding: 0 ${spacing * 4}px;\n cursor: default;\n color: ${(props) => props.theme.header?.menuItemColor};\n`;\n","import {hideTooltip, showTooltip, Position} from '@propellerads/smart-tooltip';\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport type {FC} from 'react';\nimport {useEffect, useState} from 'react';\nimport {StyledHeaderTime} from './style';\n\ndayjs.extend(utc);\n\nconst getTime = () => {\n return dayjs.utc().subtract(5, 'hour');\n};\n\ntype HeaderTimeProps = {\n tooltipContent?: (ESTDate: dayjs.Dayjs) => string;\n};\n\nconst HeaderTime: FC<HeaderTimeProps> = ({\n tooltipContent = (ESTDate) => `System time: ${ESTDate.format('HH:mm DD.MM')} (EST)`,\n}) => {\n const [time, setTime] = useState(getTime());\n\n useEffect(() => {\n const timer = setInterval(() => {\n setTime(getTime());\n }, 1000);\n\n return () => clearInterval(timer);\n }, []);\n\n return (\n <StyledHeaderTime\n onMouseEnter={(e) => {\n showTooltip(e.currentTarget, tooltipContent(time), Position.Bottom);\n }}\n onMouseLeave={hideTooltip}\n >\n {`${time.format('HH:mm')} EST`}\n </StyledHeaderTime>\n );\n};\n\nexport default HeaderTime;\n","import styled from 'styled-components';\n\nconst StyledHeaderDivider = styled.div`\n width: 1px;\n height: 20px;\n background-color: ${(props) => props.theme.header?.dividerColor};\n`;\n\nexport {StyledHeaderDivider};\n","import type {FC} from 'react';\nimport {StyledHeaderDivider} from './style';\n\nconst HeaderDivider: FC = () => <StyledHeaderDivider />;\n\nexport default HeaderDivider;\n","import styled from 'styled-components';\nimport {spacing, smallDevices, borderRadius} from '@propellerads/stylevariables';\n\nconst StyledHeaderDropdown = styled.div`\n border-radius: ${borderRadius}px;\n box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.1);\n padding: ${spacing * 2}px 0;\n width: 100%;\n background-color: ${(props) => props.theme.header?.menuItemBackgroundColor};\n\n @media (min-width: ${smallDevices}px) {\n width: auto;\n min-width: 150px;\n }\n`;\n\nexport {StyledHeaderDropdown};\n","import type {FC, ReactNode} from 'react';\nimport {StyledHeaderDropdown} from './style';\n\ntype HeaderDropdownProps = {\n id?: string;\n children: ReactNode;\n};\n\nconst HeaderDropdown: FC<HeaderDropdownProps> = ({id, children}) => (\n <StyledHeaderDropdown id={id}>{children}</StyledHeaderDropdown>\n);\n\nexport default HeaderDropdown;\n","import styled from 'styled-components';\nimport {spacing} from '@propellerads/stylevariables';\n\nconst StyledHeaderDropdownItem = styled.div`\n height: 48px;\n padding: 0 16px;\n position: relative;\n display: flex;\n align-items: center;\n cursor: pointer;\n text-align: left;\n background-color: ${(props) => props.theme.header?.menuItemBackgroundColor};\n color: ${(props) => props.theme.header?.menuItemColor};\n\n &:hover {\n background-color: ${(props) => props.theme.header?.menuItemBackgroundColorHover};\n color: ${(props) => props.theme.header?.menuItemColorHover};\n }\n\n & > * {\n border: 0;\n margin: 0;\n color: inherit !important;\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n display: flex;\n align-items: center;\n padding: 0 ${spacing * 4}px;\n outline: none;\n font-size: inherit;\n background: transparent;\n transition: color 200ms ease-out;\n text-decoration: none;\n }\n`;\n\nexport {StyledHeaderDropdownItem};\n","import type {FC, ReactNode} from 'react';\nimport {StyledHeaderDropdownItem} from './style';\n\ntype HeaderDropdownItemProps = {\n item: ReactNode;\n};\n\nconst HeaderDropdownItem: FC<HeaderDropdownItemProps> = ({item}) => (\n <StyledHeaderDropdownItem>{item}</StyledHeaderDropdownItem>\n);\n\ntype HeaderDropdownListProps = {\n items?: ReactNode[];\n};\n\nconst HeaderDropdownList: FC<HeaderDropdownListProps> = ({items = []}) => (\n <>\n {items.map((item, idx) => (\n <HeaderDropdownItem key={idx} item={item} />\n ))}\n </>\n);\n\nexport default HeaderDropdownList;\n","import type {CSSObject} from 'styled-components';\nimport styled from 'styled-components';\n\ntype StyledHeaderProps = {\n $customHeaderStyle: CSSObject;\n};\n\nconst StyledHeader = styled.div<StyledHeaderProps>`\n display: flex;\n height: 56px;\n align-items: center;\n justify-content: space-between;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n z-index: 2001;\n background-color: ${(props) => props.theme?.header?.backgroundColor};\n box-shadow: ${(props) => props.theme?.header?.boxShadow};\n\n ${(props) => props.$customHeaderStyle}\n`;\n\nconst StyledHeaderBrand = styled.div`\n display: flex;\n align-items: center;\n`;\n\nconst StyledHeaderOptions = styled.div`\n display: flex;\n align-items: center;\n height: 100%;\n`;\n\nexport {StyledHeader, StyledHeaderBrand, StyledHeaderOptions};\n","import {Theme} from '@propellerads/theme-annotation';\n\nexport const ThemeName = {\n Dark: 'dark',\n Light: 'light',\n Transparent: 'transparent',\n} as const;\nexport type ThemeName = (typeof ThemeName)[keyof typeof ThemeName];\n\nexport type HeaderTheme = Pick<Theme, 'header' | 'balance'>;\n","import {actionColor, black, gray50, gray70, gray80, gray95, white} from '@propellerads/stylevariables';\nimport {HeaderTheme, ThemeName} from './types';\n\nconst themes: Record<ThemeName, HeaderTheme> = {\n [ThemeName.Dark]: {\n header: {\n backgroundColor: 'hsl(228, 16.9%, 17.5%)',\n color: gray70,\n colorHover: white,\n boxShadow: '0 2px 8px 0 hsla(0, 0%, 0%, 0.1)',\n dividerColor: gray50,\n menuItemColor: gray70,\n menuItemColorHover: white,\n menuItemBackgroundColor: 'hsl(228, 16.9%, 17.5%)',\n menuItemBackgroundColorHover: 'hsla(0, 0%, 0%, 0.3)',\n },\n balance: {\n borderColor: gray80,\n textColor: white,\n dailyEarnedColor: white,\n chartColor: black,\n chartBackgroundColor: white,\n },\n },\n [ThemeName.Light]: {\n header: {\n backgroundColor: white,\n color: gray70,\n colorHover: black,\n boxShadow: '0 2px 8px 0 hsla(0, 0%, 0%, 0.1)',\n dividerColor: gray95,\n menuItemColor: gray70,\n menuItemColorHover: black,\n menuItemBackgroundColor: white,\n menuItemBackgroundColorHover: gray95,\n },\n balance: {\n borderColor: gray80,\n textColor: actionColor,\n dailyEarnedColor: actionColor,\n chartColor: white,\n chartBackgroundColor: black,\n },\n },\n [ThemeName.Transparent]: {\n header: {\n backgroundColor: 'none',\n color: gray70,\n colorHover: black,\n dividerColor: gray50,\n menuItemColor: gray70,\n menuItemColorHover: white,\n menuItemBackgroundColor: 'hsl(228, 16.9%, 17.5%)',\n menuItemBackgroundColorHover: 'hsla(0, 0%, 0%, 0.3)',\n boxShadow: 'none',\n },\n balance: {\n borderColor: gray80,\n textColor: actionColor,\n dailyEarnedColor: actionColor,\n chartColor: white,\n chartBackgroundColor: black,\n },\n },\n};\n\nexport default themes;\n","import type {FC, ReactNode} from 'react';\nimport {useContext} from 'react';\nimport {ThemeContext} from 'styled-components';\nimport themes from './variables';\nimport {Theme} from '@propellerads/theme-annotation';\n\ntype ThemeContextProps = {\n theme?: Pick<Theme, 'header' | 'balance'>;\n children: ReactNode;\n};\n\nexport const ThemeContextProvider: FC<ThemeContextProps> = ({theme = themes.light, children}) => (\n <ThemeContext.Provider value={theme}>{children}</ThemeContext.Provider>\n);\n\nexport const useThemeContext = () => useContext(ThemeContext);\n","import type {FC, ReactNode} from 'react';\nimport type {CSSObject} from 'styled-components';\nimport HeaderItem from './HeaderItem';\nimport HeaderBalance from './HeaderBalance';\nimport HeaderTime from './HeaderTime';\nimport HeaderDivider from './HeaderDivider';\nimport HeaderDropdown from './HeaderDropdown';\nimport HeaderDropdownList from './HeaderDropdownList';\nimport {StyledHeader, StyledHeaderOptions, StyledHeaderBrand} from './style';\nimport {ThemeContextProvider} from './themes/context';\nimport themes from './themes/variables';\nimport type {HeaderTheme} from './themes/types';\nimport {ThemeName} from './themes/types';\n\ntype HeaderProps = {\n logo: ReactNode;\n customHeaderStyle?: CSSObject;\n sidebarButton?: ReactNode;\n children: ReactNode;\n theme?: HeaderTheme;\n id?: string;\n};\n\ntype HeaderCompound = FC<HeaderProps> & {\n Item: typeof HeaderItem;\n Balance: typeof HeaderBalance;\n Time: typeof HeaderTime;\n Divider: typeof HeaderDivider;\n Dropdown: typeof HeaderDropdown;\n DropdownList: typeof HeaderDropdownList;\n};\n\nconst HeaderRoot: FC<HeaderProps> = ({\n logo,\n customHeaderStyle = {},\n sidebarButton,\n children,\n theme,\n id = 'header-container',\n}) => (\n <ThemeContextProvider {...(theme ? {theme} : {})}>\n <StyledHeader id={id} $customHeaderStyle={customHeaderStyle}>\n <StyledHeaderBrand>\n {sidebarButton}\n {logo}\n </StyledHeaderBrand>\n\n <StyledHeaderOptions>{children}</StyledHeaderOptions>\n </StyledHeader>\n </ThemeContextProvider>\n);\n\nconst Header: HeaderCompound = Object.assign(HeaderRoot, {\n Item: HeaderItem,\n Balance: HeaderBalance,\n Time: HeaderTime,\n Divider: HeaderDivider,\n Dropdown: HeaderDropdown,\n DropdownList: HeaderDropdownList,\n});\n\nexport default Header;\nexport type {HeaderProps};\nexport {themes, ThemeName};\n"],"mappings":";;;;;;;;;AAGA,IAAa,KACX,GACA,MACS;CACT,QAAgB;EACd,IAAM,KAAY,MAAmC;GACnD,IAAM,IAAK,EAAI;GACX,CAAC,KAAM,EAAG,SAAS,EAAM,OAAe,IAG5C,EAAQ,EAAM;;EAMhB,OAHA,SAAS,iBAAiB,aAAa,EAAS,EAChD,SAAS,iBAAiB,cAAc,EAAS,QAEpC;GAEX,AADA,SAAS,oBAAoB,aAAa,EAAS,EACnD,SAAS,oBAAoB,cAAc,EAAS;;IAErD,CAAC,GAAK,EAAQ,CAAC;GCpBd,IAAmB,EAAO,GAAG;;;;;GAO7B,IAAyB,EAAO,MAAM;;;;;eAK7B,EAAW;;;eAGX,IAAU,EAAE;;;YAGf,MAAU,EAAM,MAAM,QAAQ,cAAc;;;cAG1C,MAA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X,cAAc;GACd,eAAe;GACf,oBAAoB;GACpB,yBAAyB;GACzB,8BAA8B;GAC/B;EACD,SAAS;GACP,aAAa;GACb,WAAW;GACX,kBAAkB;GAClB,YAAY;GACZ,sBAAsB;GACvB;EACF;EACA,EAAU,QAAQ;EACjB,QAAQ;GACN,iBAAiB;GACjB,OAAO;GACP,YAAY;GACZ,WAAW;GACX,cAAc;GACd,eAAe;GACf,oBAAoB;GACpB,yBAAyB;GACzB,8BAA8B;GAC/B;EACD,SAAS;GACP,aAAa;GACb,WAAW;GACX,kBAAkB;GAClB,YAAY;GACZ,sBAAsB;GACvB;EACF;EACA,EAAU,cAAc;EACvB,QAAQ;GACN,iBAAiB;GACjB,OAAO;GACP,YAAY;GACZ,cAAc;GACd,eAAe;GACf,oBAAoB;GACpB,yBAAyB;GACzB,8BAA8B;GAC9B,WAAW;GACZ;EACD,SAAS;GACP,aAAa;GACb,WAAW;GACX,kBAAkB;GAClB,YAAY;GACZ,sBAAsB;GACvB;EACF;CACF,ECrDY,MAA+C,EAAC,WAAQ,EAAO,OAAO,kBACjF,kBAAC,EAAa,UAAd;CAAuB,OAAO;CAAQ;CAAiC,CAAA,ECwCnE,KAAyB,OAAO,QApBD,EACnC,SACA,uBAAoB,EAAE,EACtB,kBACA,aACA,UACA,QAAK,yBAEL,kBAAC,IAAD;CAAsB,GAAK,IAAQ,EAAC,UAAM,GAAG,EAAE;WAC7C,kBAAC,GAAD;EAAkB;EAAI,oBAAoB;YAA1C,CACE,kBAAC,GAAD,EAAA,UAAA,CACG,GACA,EACiB,EAAA,CAAA,EAEpB,kBAAC,GAAD,EAAsB,aAA+B,CAAA,CACxC;;CACM,CAAA,EAGgC;CACvD,MAAM;CACN,SAAS;CACT,MAAM;CACN,SAAS;CACT,UAAU;CACV,cAAc;CACf,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/balance.tsx","../src/cn.ts","../src/context.ts","../src/item.tsx","../src/time.tsx","../src/types.ts","../src/index.tsx"],"sourcesContent":["import {Position, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from '@propellerads/smart-tooltip';\nimport type {DayEarned, HeaderBalanceProps} from './types';\n\n/* @propellerads/currency's formatting, inlined: the package still draws its\n code with styled-components, and the header has no other use for it. */\nconst formatMoney = (value: number, decimals = 2) => value.toFixed(decimals).replace(/(\\d)(?=(\\d{3})+\\.)/g, '$1,');\n\nconst Money = ({value, decimals}: {value: number; decimals?: number}) => (\n <span>\n <span className=\"header__currency\">$</span>\n {formatMoney(value, decimals)}\n </span>\n);\n\nconst Bar = ({day}: {day: DayEarned}) => (\n <Tooltip>\n <TooltipTrigger render={<span />} className=\"header__bar\">\n <span className=\"header__bar-value\" style={{height: day.percentage > 1 ? `${day.percentage}%` : '1px'}} />\n </TooltipTrigger>\n <TooltipContent side={Position.Bottom}>\n {day.date} — <Money value={day.value} />\n </TooltipContent>\n </Tooltip>\n);\n\n/**\n * The balance and, beside it, a bar per day. Each bar names its day in a\n * SmartTooltip; the tooltips share one provider with no delay, so running the\n * pointer along the bars reads them one after another the way v7's labels did.\n */\nconst HeaderBalance = ({balance, dailyEarned = []}: HeaderBalanceProps) => (\n <div className=\"header__balance\">\n <span className=\"header__balance-value\">\n <Money value={balance} />\n </span>\n\n {dailyEarned.length > 0 && (\n <TooltipProvider delay={0} closeDelay={0}>\n <span className=\"header__chart\">\n {dailyEarned.map((day, index) => (\n <Bar key={index} day={day} />\n ))}\n </span>\n </TooltipProvider>\n )}\n </div>\n);\n\nexport {HeaderBalance};\n","import {type ClassValue, clsx} from 'clsx';\n\n/**\n * Joins class names. There is no tailwind-merge here on purpose: the header\n * ships its own stylesheet instead of utility classes, so there is nothing to\n * deduplicate.\n */\nconst cn = (...inputs: ClassValue[]): string => clsx(inputs);\n\nexport {cn};\n","import {createContext, type RefObject, useContext} from 'react';\nimport type {ThemeName} from './types';\n\ntype HeaderContextValue = {\n /** The bar itself: on a phone a dropdown hangs off it rather than off its item. */\n barRef: RefObject<HTMLElement | null>;\n theme: ThemeName;\n};\n\nconst HeaderContext = createContext<HeaderContextValue | null>(null);\n\nconst useHeader = () => useContext(HeaderContext);\n\nexport {HeaderContext, useHeader};\n","import {Popover} from '@base-ui-components/react/popover';\nimport {useState, useSyncExternalStore} from 'react';\nimport {cn} from './cn';\nimport {useHeader} from './context';\nimport type {HeaderDropdownListProps, HeaderDropdownProps, HeaderItemProps} from './types';\n\n/* Below the tablet breakpoint a dropdown spans the bar rather than standing\n under its item, as v7's did. The number repeats --breakpoint-tablet: a media\n query cannot read a custom property. */\nconst MOBILE_QUERY = '(max-width: 768px)';\n\nconst subscribeToMobile = (onChange: () => void) => {\n const query = window.matchMedia(MOBILE_QUERY);\n query.addEventListener('change', onChange);\n return () => query.removeEventListener('change', onChange);\n};\n\nconst useIsMobile = (): boolean =>\n useSyncExternalStore(\n subscribeToMobile,\n () => window.matchMedia(MOBILE_QUERY).matches,\n () => false,\n );\n\nconst Content = ({icon, title, component}: Pick<HeaderItemProps, 'icon' | 'title' | 'component'>) => (\n <>\n {icon}\n {title !== undefined && <span className=\"header__item-title\">{title}</span>}\n {component}\n </>\n);\n\n/**\n * One control of the bar: a plain button with `onClick`, a dropdown trigger\n * with `children`, or both missing — then it is a button that does nothing,\n * which a product wraps to hang its own behaviour on (Beamer does).\n *\n * The dropdown is shadcn's Popover on Base UI: it stands under the item, takes\n * the focus when it opens, gives it back to the item when it closes, and closes\n * on Escape and on a press outside. A click anywhere inside it closes it too,\n * as v7's did — a menu row has done its job once clicked. Content that has to\n * stay open under a click stops the event's propagation, which works the same\n * through the portal.\n */\nconst HeaderItem = ({\n id,\n className,\n children,\n onClick,\n component,\n icon,\n title,\n isRightDropdown = false,\n 'aria-label': ariaLabel,\n}: HeaderItemProps) => {\n const header = useHeader();\n const isMobile = useIsMobile();\n const [isOpen, setIsOpen] = useState(false);\n\n const content = <Content icon={icon} title={title} component={component} />;\n const hasDropdown = children !== undefined && children !== null && onClick === undefined;\n\n if (!hasDropdown) {\n return (\n <div id={id} className={cn('header__item', className)}>\n <button type=\"button\" className=\"header__item-button\" aria-label={ariaLabel} onClick={onClick}>\n {content}\n </button>\n </div>\n );\n }\n\n return (\n <div id={id} className={cn('header__item', className)}>\n <Popover.Root open={isOpen} onOpenChange={setIsOpen}>\n <Popover.Trigger className=\"header__item-button\" aria-label={ariaLabel}>\n {content}\n </Popover.Trigger>\n <Popover.Portal>\n <Popover.Positioner\n className={cn('header__positioner', `header-theme--${header?.theme ?? 'light'}`)}\n anchor={isMobile ? header?.barRef : undefined}\n side=\"bottom\"\n align={isRightDropdown || isMobile ? 'end' : 'start'}\n sideOffset={isMobile ? 0 : 4}\n collisionPadding={8}\n >\n <Popover.Popup\n className={cn('header__popup', isMobile && 'header__popup--wide')}\n onClick={() => setIsOpen(false)}\n >\n {children}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n </div>\n );\n};\n\n/** The pad of a dropdown. Its `id` is where products hang their overrides. */\nconst HeaderDropdown = ({id, className, children}: HeaderDropdownProps) => (\n <div id={id} className={cn('header__dropdown', className)}>\n {children}\n </div>\n);\n\n/** Rows of a menu: what is in a row fills it, so the whole row is the hit area. */\nconst HeaderDropdownList = ({items = []}: HeaderDropdownListProps) => (\n <div className=\"header__menu\">\n {items.map((item, index) => (\n // The rows are whatever the product passed and carry no identity of their own.\n <div key={index} className=\"header__menu-item\">\n {item}\n </div>\n ))}\n </div>\n);\n\nexport {HeaderDropdown, HeaderDropdownList, HeaderItem};\n","import {Position, Tooltip, TooltipContent, TooltipTrigger} from '@propellerads/smart-tooltip';\nimport dayjs from 'dayjs';\nimport utc from 'dayjs/plugin/utc';\nimport {useEffect, useState} from 'react';\nimport type {HeaderTimeProps} from './types';\n\ndayjs.extend(utc);\n\n/* v7's arithmetic, kept as is: UTC−5 all year, with no daylight saving. */\nconst now = () => dayjs.utc().subtract(5, 'hour');\n\nconst defaultContent: NonNullable<HeaderTimeProps['tooltipContent']> = (date) =>\n `System time: ${date.format('HH:mm DD.MM')} (EST)`;\n\n/** The system time, in EST, with the date in a tooltip. */\nconst HeaderTime = ({tooltipContent = defaultContent}: HeaderTimeProps) => {\n const [time, setTime] = useState(now);\n\n useEffect(() => {\n const timer = setInterval(() => setTime(now()), 1000);\n\n return () => clearInterval(timer);\n }, []);\n\n return (\n <Tooltip>\n <TooltipTrigger render={<span />} className=\"header__time\">\n {`${time.format('HH:mm')} EST`}\n </TooltipTrigger>\n <TooltipContent side={Position.Bottom}>{tooltipContent(time)}</TooltipContent>\n </Tooltip>\n );\n};\n\nexport {HeaderTime};\n","import type {Dayjs} from 'dayjs';\nimport type {CSSProperties, ReactNode} from 'react';\n\n/**\n * What the bar is worn in.\n *\n * `light` is the page itself: the tokens' surface and text, so it turns over\n * with the theme the product writes on <html>. `dark` stays dark on a light\n * page as well — the dark theme's greys, scoped to the bar and its dropdowns.\n * `transparent` is `light` with the surface and the shadow taken away, for a\n * bar laid over a page that draws its own background.\n */\nexport const ThemeName = {\n Dark: 'dark',\n Light: 'light',\n Transparent: 'transparent',\n} as const;\nexport type ThemeName = (typeof ThemeName)[keyof typeof ThemeName];\n\nexport type HeaderProps = {\n /** The brand: a logo, a link home. */\n logo: ReactNode;\n /** Stands before the logo, usually an `Header.Item` that opens the sidebar. */\n sidebarButton?: ReactNode;\n /** The right-hand side: items, dividers, the balance, the time. */\n children: ReactNode;\n /** @default 'light' */\n theme?: ThemeName;\n /** @default 'header-container' — products find the bar by it. */\n id?: string;\n className?: string;\n style?: CSSProperties;\n /** @deprecated Use `style`. Kept for the products that still pass it. */\n customHeaderStyle?: CSSProperties;\n};\n\nexport type HeaderItemProps = {\n /** Lands on the item's wrapper. */\n id?: string;\n className?: string;\n /**\n * The dropdown, usually a `Header.Dropdown`. Clicking the item opens it,\n * clicking anything inside it closes it. Ignored when `onClick` is given.\n */\n children?: ReactNode;\n /** Makes the item a plain button: no dropdown opens. */\n onClick?: () => void;\n /** Free content of the button, after the icon and the title. */\n component?: ReactNode;\n icon?: ReactNode;\n title?: string;\n /** Aligns the dropdown to the item's right edge instead of its left. */\n isRightDropdown?: boolean;\n /** The button's accessible name, for an item that is only an icon. */\n 'aria-label'?: string;\n};\n\nexport type HeaderDropdownProps = {\n id?: string;\n className?: string;\n children: ReactNode;\n};\n\nexport type HeaderDropdownListProps = {\n /** One row each. A link or a button in a row fills the whole row. */\n items?: ReactNode[];\n};\n\nexport type DayEarned = {\n date: string;\n value: number;\n /** The bar's height, 0–100. Below 1 the bar is a hairline. */\n percentage: number;\n};\n\nexport type HeaderBalanceProps = {\n balance: number;\n /** A bar per day beside the balance, hidden below the tablet breakpoint. */\n dailyEarned?: DayEarned[];\n};\n\nexport type HeaderTimeProps = {\n /** What the tooltip says, given the current time in EST. */\n tooltipContent?: (ESTDate: Dayjs) => ReactNode;\n};\n","import {useMemo, useRef} from 'react';\nimport './header.css';\nimport {HeaderBalance} from './balance';\nimport {cn} from './cn';\nimport {HeaderContext} from './context';\nimport {HeaderDropdown, HeaderDropdownList, HeaderItem} from './item';\nimport {HeaderTime} from './time';\nimport {\n type DayEarned,\n type HeaderBalanceProps,\n type HeaderDropdownListProps,\n type HeaderDropdownProps,\n type HeaderItemProps,\n type HeaderProps,\n type HeaderTimeProps,\n ThemeName,\n} from './types';\n\n/**\n * v7 took a theme object and products wrote `theme={themes.dark}`. The object\n * is a name now, and `themes` maps each name onto itself, so that line keeps\n * working.\n *\n * @deprecated Pass `ThemeName.Dark` or `'dark'`.\n */\nconst themes: Record<ThemeName, ThemeName> = {\n [ThemeName.Dark]: ThemeName.Dark,\n [ThemeName.Light]: ThemeName.Light,\n [ThemeName.Transparent]: ThemeName.Transparent,\n};\n\n/* A product may still hand over a v7 theme object, a copy of one or one of\n its own; it gets the light bar rather than a broken one. */\nconst toThemeName = (theme: unknown): ThemeName =>\n Object.values(ThemeName).includes(theme as ThemeName) ? (theme as ThemeName) : ThemeName.Light;\n\nconst HeaderDivider = () => <span className=\"header__divider\" aria-hidden=\"true\" />;\n\nconst HeaderRoot = ({\n logo,\n sidebarButton,\n children,\n theme,\n id = 'header-container',\n className,\n style,\n customHeaderStyle,\n}: HeaderProps) => {\n const barRef = useRef<HTMLElement | null>(null);\n const themeName = toThemeName(theme);\n const context = useMemo(() => ({barRef, theme: themeName}), [themeName]);\n\n return (\n <HeaderContext.Provider value={context}>\n <header\n ref={barRef}\n id={id}\n className={cn('header', `header-theme--${themeName}`, className)}\n style={{...customHeaderStyle, ...style}}\n >\n <div className=\"header__brand\">\n {sidebarButton}\n {logo}\n </div>\n\n <div className=\"header__options\">{children}</div>\n </header>\n </HeaderContext.Provider>\n );\n};\n\ntype HeaderCompound = typeof HeaderRoot & {\n Item: typeof HeaderItem;\n Balance: typeof HeaderBalance;\n Time: typeof HeaderTime;\n Divider: typeof HeaderDivider;\n Dropdown: typeof HeaderDropdown;\n DropdownList: typeof HeaderDropdownList;\n};\n\nconst Header: HeaderCompound = Object.assign(HeaderRoot, {\n Item: HeaderItem,\n Balance: HeaderBalance,\n Time: HeaderTime,\n Divider: HeaderDivider,\n Dropdown: HeaderDropdown,\n DropdownList: HeaderDropdownList,\n});\n\nexport default Header;\nexport type {\n DayEarned,\n HeaderBalanceProps,\n HeaderDropdownListProps,\n HeaderDropdownProps,\n HeaderItemProps,\n HeaderProps,\n HeaderTimeProps,\n};\nexport {\n Header,\n HeaderBalance,\n HeaderDivider,\n HeaderDropdown,\n HeaderDropdownList,\n HeaderItem,\n HeaderTime,\n ThemeName,\n themes,\n};\n"],"mappings":";;;;;;;;AAKA,IAAM,KAAe,GAAe,IAAW,MAAM,EAAM,QAAQ,EAAS,CAAC,QAAQ,uBAAuB,MAAM,EAE5G,KAAS,EAAC,UAAO,kBACrB,kBAAC,QAAD,EAAA,UAAA,CACE,kBAAC,QAAD;CAAM,WAAU;WAAmB;CAAQ,CAAA,EAC1C,EAAY,GAAO,EAAS,CACxB,EAAA,CAAA,EAGH,KAAO,EAAC,aACZ,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;CAAgB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;IAAmB;IAAe,CAAA,CAC1C;;EACc,CAAA;GAa4B;CACvD,MAAM;CACN,SAAS;CACT,MAAM;CACN,SAAS;CACT,UAAU;CACV,cAAc;CACf,CAAC"}
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "@propellerads/header",
3
- "version": "7.0.4",
3
+ "version": "8.0.1",
4
4
  "type": "module",
5
5
  "types": "dist/index.d.ts",
6
+ "style": "dist/index.css",
6
7
  "exports": {
7
8
  ".": {
8
9
  "types": "./dist/index.d.ts",
9
10
  "import": "./dist/index.js"
10
- }
11
+ },
12
+ "./index.css": "./dist/index.css"
11
13
  },
14
+ "sideEffects": [
15
+ "**/*.css"
16
+ ],
12
17
  "files": [
13
18
  "dist"
14
19
  ],
@@ -24,22 +29,29 @@
24
29
  "homepage": "https://github.com/propellerads/ui-components#readme",
25
30
  "private": false,
26
31
  "dependencies": {
27
- "@propellerads/currency": "^5.0.1",
32
+ "@base-ui-components/react": "1.0.0-rc.0",
28
33
  "@propellerads/smart-tooltip": "^8.0.0",
29
- "@propellerads/stylevariables": "^2.0.2",
30
- "@propellerads/theme-annotation": "^2.1.1",
34
+ "clsx": "^2.1.1",
31
35
  "dayjs": "^1.11.20"
32
36
  },
33
37
  "peerDependencies": {
38
+ "@propellerads/tokens": ">=0.3.0",
34
39
  "react": "^18.0.0 || ^19.0.0",
35
- "styled-components": "^5.1.1 || ^6.0.0"
40
+ "react-dom": "^18.0.0 || ^19.0.0"
41
+ },
42
+ "peerDependenciesMeta": {
43
+ "@propellerads/tokens": {
44
+ "optional": true
45
+ }
36
46
  },
37
47
  "devDependencies": {
48
+ "@propellerads/tokens": "workspace:^",
38
49
  "@types/react": "^19.2.14",
39
50
  "@vitejs/plugin-react": "^6.0.1",
40
51
  "rollup": "^4.60.3",
41
52
  "rollup-plugin-dts": "^6.4.1",
42
53
  "typescript": "^6.0.3",
43
- "vite": "^8.0.11"
54
+ "vite": "^8.0.11",
55
+ "vite-plugin-lib-inject-css": "^2.2.2"
44
56
  }
45
57
  }