@pushwoosh/dumb-components 1.1.196 → 1.1.198

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.
@@ -0,0 +1 @@
1
+ export { LeafletTheme } from './styles';
@@ -0,0 +1 @@
1
+ export { LeafletTheme } from './styles';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Repaints Leaflet's own chrome with Pushwoosh tokens — map surface, zoom buttons,
3
+ * attribution, scale, popups and tooltips — and darkens light raster tiles in the dark theme.
4
+ * @example
5
+ * <LeafletTheme />
6
+ */
7
+ export declare const LeafletTheme: import("styled-components").GlobalStyleComponent<{}, import("styled-components").DefaultTheme>;
@@ -0,0 +1,10 @@
1
+ import { createGlobalStyle } from 'styled-components';
2
+ import { Color, THEME_ATTRIBUTE } from '@pushwoosh/kit-constants';
3
+ const DARK_TILES = 'invert(1) hue-rotate(180deg) brightness(0.9) contrast(1.05) saturate(0.55)';
4
+ /**
5
+ * Repaints Leaflet's own chrome with Pushwoosh tokens — map surface, zoom buttons,
6
+ * attribution, scale, popups and tooltips — and darkens light raster tiles in the dark theme.
7
+ * @example
8
+ * <LeafletTheme />
9
+ */
10
+ export const LeafletTheme = createGlobalStyle([".leaflet-container{background:", ";color:", ";}.leaflet-container a{color:", ";}.leaflet-bar a,.leaflet-control-layers-toggle{background-color:", ";color:", ";border-bottom-color:", ";}.leaflet-bar a:hover,.leaflet-bar a:focus{background-color:", ";color:", ";}.leaflet-bar a.leaflet-disabled{background-color:", ";color:", ";}.leaflet-touch .leaflet-bar,.leaflet-touch .leaflet-control-layers{border-color:", ";}.leaflet-control-layers{background:", ";color:", ";}.leaflet-container .leaflet-control-attribution{background:", ";color:", ";}.leaflet-control-scale-line{background:", ";color:", ";border-color:", ";text-shadow:none;}.leaflet-popup-content-wrapper,.leaflet-popup-tip{background:", ";color:", ";}.leaflet-container a.leaflet-popup-close-button{color:", ";}.leaflet-container a.leaflet-popup-close-button:hover,.leaflet-container a.leaflet-popup-close-button:focus{color:", ";}.leaflet-tooltip{background-color:", ";border-color:", ";color:", ";}.leaflet-tooltip-top:before{border-top-color:", ";}.leaflet-tooltip-bottom:before{border-bottom-color:", ";}.leaflet-tooltip-left:before{border-left-color:", ";}.leaflet-tooltip-right:before{border-right-color:", ";}.leaflet-div-icon{background:", ";border-color:", ";}.leaflet-zoom-box{border-color:", ";background:", ";}[", "='dark'] .leaflet-tile-pane{filter:", ";}"], Color.FROZEN, Color.MAIN, Color.PRIMARY, Color.CLEAR, Color.MAIN, Color.FORM, Color.FROZEN, Color.MAIN, Color.FROZEN, Color.PHANTOM, Color.FORM, Color.CLEAR, Color.MAIN, Color.CLEAR, Color.LOCKED, Color.CLEAR, Color.MAIN, Color.FORM, Color.CLEAR, Color.MAIN, Color.LOCKED, Color.MAIN, Color.CLEAR, Color.CLEAR, Color.MAIN, Color.CLEAR, Color.CLEAR, Color.CLEAR, Color.CLEAR, Color.CLEAR, Color.FORM, Color.PRIMARY, Color.BRIGHT_LIGHT, THEME_ATTRIBUTE, DARK_TILES);
package/Select/Select.js CHANGED
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { CloseIcon } from '@pushwoosh/kit-icons';
3
3
  import { CLASS_NAME_PREFIX } from './constants';
4
4
  import { SelectStyled, SelectAsyncStyled, ClearIndicatorBox } from './styles';
5
+ import { withThemeStyles } from './themeStyles';
5
6
  const componentsProps = {
6
7
  ClearIndicator: ({
7
8
  clearValue
@@ -24,11 +25,13 @@ const componentsProps = {
24
25
  */
25
26
  export function Select(props) {
26
27
  const {
27
- classNamePrefix = CLASS_NAME_PREFIX
28
+ classNamePrefix = CLASS_NAME_PREFIX,
29
+ styles
28
30
  } = props;
29
31
  const customProps = {
30
32
  ...props,
31
- classNamePrefix
33
+ classNamePrefix,
34
+ styles: withThemeStyles(styles)
32
35
  };
33
36
  return _jsx(SelectStyled, {
34
37
  components: componentsProps,
@@ -44,11 +47,13 @@ export function Select(props) {
44
47
  */
45
48
  export function SelectAsync(props) {
46
49
  const {
47
- classNamePrefix = CLASS_NAME_PREFIX
50
+ classNamePrefix = CLASS_NAME_PREFIX,
51
+ styles
48
52
  } = props;
49
53
  const customProps = {
50
54
  ...props,
51
- classNamePrefix
55
+ classNamePrefix,
56
+ styles: withThemeStyles(styles)
52
57
  };
53
58
  return _jsx(SelectAsyncStyled, {
54
59
  components: componentsProps,
@@ -0,0 +1,6 @@
1
+ import type { GroupBase, StylesConfig } from 'react-select';
2
+ /**
3
+ * Merges the Pushwoosh select theme under a caller's own `styles`, so theirs still wins.
4
+ * Goes through `styles`, not CSS: a menu portalled into `body` escapes the styled wrapper.
5
+ */
6
+ export declare function withThemeStyles<Option, IsMulti extends boolean, Group extends GroupBase<Option>>(styles?: StylesConfig<Option, IsMulti, Group>): StylesConfig<Option, IsMulti, Group>;
@@ -0,0 +1,72 @@
1
+ import { Color, FontWeight, Shadow } from '@pushwoosh/kit-constants';
2
+ const themeStyles = {
3
+ menu: base => ({
4
+ ...base,
5
+ backgroundColor: Color.CLEAR,
6
+ boxShadow: Shadow.REGULAR
7
+ }),
8
+ menuList: base => ({
9
+ ...base,
10
+ backgroundColor: Color.CLEAR
11
+ }),
12
+ option: (base, state) => ({
13
+ ...base,
14
+ color: Color.MAIN,
15
+ fontWeight: state.isSelected ? FontWeight.MEDIUM : FontWeight.REGULAR,
16
+ backgroundColor: (() => {
17
+ if (state.isSelected && state.isFocused) return Color.BRIGHT_LIGHT_HOVER;
18
+ if (state.isSelected) return Color.BRIGHT_LIGHT;
19
+ if (state.isFocused) return Color.SOFT_LIGHT;
20
+ return 'transparent';
21
+ })(),
22
+ ':active': {
23
+ backgroundColor: Color.BRIGHT_LIGHT_HOVER
24
+ }
25
+ }),
26
+ singleValue: base => ({
27
+ ...base,
28
+ color: Color.MAIN
29
+ }),
30
+ multiValueLabel: base => ({
31
+ ...base,
32
+ color: Color.PRIMARY
33
+ }),
34
+ input: base => ({
35
+ ...base,
36
+ color: Color.MAIN
37
+ }),
38
+ placeholder: base => ({
39
+ ...base,
40
+ color: Color.PHANTOM
41
+ }),
42
+ groupHeading: base => ({
43
+ ...base,
44
+ color: Color.LOCKED
45
+ }),
46
+ noOptionsMessage: base => ({
47
+ ...base,
48
+ color: Color.LOCKED
49
+ }),
50
+ loadingMessage: base => ({
51
+ ...base,
52
+ color: Color.LOCKED
53
+ })
54
+ };
55
+ /**
56
+ * Merges the Pushwoosh select theme under a caller's own `styles`, so theirs still wins.
57
+ * Goes through `styles`, not CSS: a menu portalled into `body` escapes the styled wrapper.
58
+ */
59
+ export function withThemeStyles(styles) {
60
+ if (!styles) return themeStyles;
61
+ const keys = new Set([...Object.keys(themeStyles), ...Object.keys(styles)]);
62
+ const merged = {};
63
+ keys.forEach(key => {
64
+ const ours = themeStyles[key];
65
+ const theirs = styles[key];
66
+ merged[key] = (base, state) => {
67
+ const themed = ours ? ours(base, state) : base;
68
+ return theirs ? theirs(themed, state) : themed;
69
+ };
70
+ });
71
+ return merged;
72
+ }
package/index.d.ts CHANGED
@@ -52,3 +52,4 @@ export { SendRateEdit, SendRateReadonly, type SendRateBase, type SendRateEditPro
52
52
  export { Alert } from './Alert';
53
53
  export { ApplicationPreloader, type ApplicationPreloaderProps, } from './ApplicationPreloader';
54
54
  export { NotificationInbox, NotificationBar, NotificationBell, type Notification, type NotificationInboxProps, type NotificationSeverity, type NotificationBarType, type NotificationBarProps, type NotificationBellProps, } from './NotificationInbox';
55
+ export { LeafletTheme } from './LeafletTheme';
package/index.js CHANGED
@@ -50,4 +50,5 @@ export { FrequencyCappingEdit, FrequencyCappingReadonly, FrequencyCappingInApps,
50
50
  export { SendRateEdit, SendRateReadonly } from './SendRate';
51
51
  export { Alert } from './Alert';
52
52
  export { ApplicationPreloader } from './ApplicationPreloader';
53
- export { NotificationInbox, NotificationBar, NotificationBell } from './NotificationInbox';
53
+ export { NotificationInbox, NotificationBar, NotificationBell } from './NotificationInbox';
54
+ export { LeafletTheme } from './LeafletTheme';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.196",
3
+ "version": "1.1.198",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",