@pushwoosh/dumb-components 4.16.0 → 4.17.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/SmsPreview/SmsPreview.d.ts +4 -0
- package/SmsPreview/SmsPreview.js +48 -0
- package/SmsPreview/index.d.ts +2 -0
- package/SmsPreview/index.js +1 -0
- package/SmsPreview/polyglot/index.d.ts +2 -0
- package/SmsPreview/polyglot/index.js +34 -0
- package/SmsPreview/polyglot/messages_ar.d.ts +3 -0
- package/SmsPreview/polyglot/messages_ar.js +5 -0
- package/SmsPreview/polyglot/messages_bn.d.ts +3 -0
- package/SmsPreview/polyglot/messages_bn.js +5 -0
- package/SmsPreview/polyglot/messages_de.d.ts +3 -0
- package/SmsPreview/polyglot/messages_de.js +5 -0
- package/SmsPreview/polyglot/messages_en.d.ts +3 -0
- package/SmsPreview/polyglot/messages_en.js +5 -0
- package/SmsPreview/polyglot/messages_es.d.ts +3 -0
- package/SmsPreview/polyglot/messages_es.js +5 -0
- package/SmsPreview/polyglot/messages_fr.d.ts +3 -0
- package/SmsPreview/polyglot/messages_fr.js +5 -0
- package/SmsPreview/polyglot/messages_he.d.ts +3 -0
- package/SmsPreview/polyglot/messages_he.js +5 -0
- package/SmsPreview/polyglot/messages_hi.d.ts +3 -0
- package/SmsPreview/polyglot/messages_hi.js +5 -0
- package/SmsPreview/polyglot/messages_ja.d.ts +3 -0
- package/SmsPreview/polyglot/messages_ja.js +5 -0
- package/SmsPreview/polyglot/messages_ko.d.ts +3 -0
- package/SmsPreview/polyglot/messages_ko.js +5 -0
- package/SmsPreview/polyglot/messages_pt.d.ts +3 -0
- package/SmsPreview/polyglot/messages_pt.js +5 -0
- package/SmsPreview/polyglot/messages_ru.d.ts +3 -0
- package/SmsPreview/polyglot/messages_ru.js +5 -0
- package/SmsPreview/polyglot/messages_th.d.ts +3 -0
- package/SmsPreview/polyglot/messages_th.js +5 -0
- package/SmsPreview/polyglot/messages_zh.d.ts +3 -0
- package/SmsPreview/polyglot/messages_zh.js +5 -0
- package/SmsPreview/polyglot/types.d.ts +9 -0
- package/SmsPreview/polyglot/types.js +1 -0
- package/SmsPreview/styles.d.ts +15 -0
- package/SmsPreview/styles.js +22 -0
- package/SmsPreview/types.d.ts +22 -0
- package/SmsPreview/types.js +1 -0
- package/Tooltip/Tooltip.d.ts +1 -1
- package/Tooltip/Tooltip.js +8 -3
- package/WalletPassPreview/WalletPassPreview.d.ts +4 -0
- package/WalletPassPreview/WalletPassPreview.js +203 -0
- package/WalletPassPreview/components/BarcodePlaceholder/BarcodePlaceholder.d.ts +3 -0
- package/WalletPassPreview/components/BarcodePlaceholder/BarcodePlaceholder.js +148 -0
- package/WalletPassPreview/components/BarcodePlaceholder/index.d.ts +1 -0
- package/WalletPassPreview/components/BarcodePlaceholder/index.js +1 -0
- package/WalletPassPreview/components/BarcodePlaceholder/styles.d.ts +6 -0
- package/WalletPassPreview/components/BarcodePlaceholder/styles.js +11 -0
- package/WalletPassPreview/components/BarcodePlaceholder/types.d.ts +3 -0
- package/WalletPassPreview/components/BarcodePlaceholder/types.js +1 -0
- package/WalletPassPreview/constants.d.ts +8 -0
- package/WalletPassPreview/constants.js +27 -0
- package/WalletPassPreview/helpers/formatting.d.ts +3 -0
- package/WalletPassPreview/helpers/formatting.js +63 -0
- package/WalletPassPreview/helpers/index.d.ts +1 -0
- package/WalletPassPreview/helpers/index.js +1 -0
- package/WalletPassPreview/index.d.ts +2 -0
- package/WalletPassPreview/index.js +1 -0
- package/WalletPassPreview/polyglot/index.d.ts +2 -0
- package/WalletPassPreview/polyglot/index.js +34 -0
- package/WalletPassPreview/polyglot/messages_ar.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_ar.js +34 -0
- package/WalletPassPreview/polyglot/messages_bn.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_bn.js +34 -0
- package/WalletPassPreview/polyglot/messages_de.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_de.js +34 -0
- package/WalletPassPreview/polyglot/messages_en.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_en.js +34 -0
- package/WalletPassPreview/polyglot/messages_es.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_es.js +34 -0
- package/WalletPassPreview/polyglot/messages_fr.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_fr.js +34 -0
- package/WalletPassPreview/polyglot/messages_he.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_he.js +34 -0
- package/WalletPassPreview/polyglot/messages_hi.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_hi.js +34 -0
- package/WalletPassPreview/polyglot/messages_ja.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_ja.js +34 -0
- package/WalletPassPreview/polyglot/messages_ko.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_ko.js +34 -0
- package/WalletPassPreview/polyglot/messages_pt.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_pt.js +34 -0
- package/WalletPassPreview/polyglot/messages_ru.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_ru.js +34 -0
- package/WalletPassPreview/polyglot/messages_th.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_th.js +34 -0
- package/WalletPassPreview/polyglot/messages_zh.d.ts +3 -0
- package/WalletPassPreview/polyglot/messages_zh.js +34 -0
- package/WalletPassPreview/polyglot/types.d.ts +47 -0
- package/WalletPassPreview/polyglot/types.js +1 -0
- package/WalletPassPreview/styles.d.ts +139 -0
- package/WalletPassPreview/styles.js +180 -0
- package/WalletPassPreview/types.d.ts +34 -0
- package/WalletPassPreview/types.js +1 -0
- package/WebPushPreview/WebPushPreview.d.ts +4 -0
- package/WebPushPreview/WebPushPreview.js +40 -0
- package/WebPushPreview/index.d.ts +2 -0
- package/WebPushPreview/index.js +1 -0
- package/WebPushPreview/polyglot/index.d.ts +5 -0
- package/WebPushPreview/polyglot/index.js +34 -0
- package/WebPushPreview/polyglot/messages_ar.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_ar.js +3 -0
- package/WebPushPreview/polyglot/messages_bn.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_bn.js +3 -0
- package/WebPushPreview/polyglot/messages_de.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_de.js +3 -0
- package/WebPushPreview/polyglot/messages_en.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_en.js +3 -0
- package/WebPushPreview/polyglot/messages_es.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_es.js +3 -0
- package/WebPushPreview/polyglot/messages_fr.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_fr.js +3 -0
- package/WebPushPreview/polyglot/messages_he.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_he.js +3 -0
- package/WebPushPreview/polyglot/messages_hi.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_hi.js +3 -0
- package/WebPushPreview/polyglot/messages_ja.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_ja.js +3 -0
- package/WebPushPreview/polyglot/messages_ko.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_ko.js +3 -0
- package/WebPushPreview/polyglot/messages_pt.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_pt.js +3 -0
- package/WebPushPreview/polyglot/messages_ru.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_ru.js +3 -0
- package/WebPushPreview/polyglot/messages_th.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_th.js +3 -0
- package/WebPushPreview/polyglot/messages_zh.d.ts +3 -0
- package/WebPushPreview/polyglot/messages_zh.js +3 -0
- package/WebPushPreview/polyglot/types.d.ts +4 -0
- package/WebPushPreview/polyglot/types.js +1 -0
- package/WebPushPreview/styles.d.ts +22 -0
- package/WebPushPreview/styles.js +31 -0
- package/WebPushPreview/types.d.ts +13 -0
- package/WebPushPreview/types.js +1 -0
- package/index.d.ts +6 -0
- package/index.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
5
|
+
import { Lang } from './polyglot';
|
|
6
|
+
import { Bubble, Phone, PhoneHeader, Placeholder, Thread } from './styles';
|
|
7
|
+
/** Renders a text message in a phone thread: sender on top, one bubble, segment count below. */
|
|
8
|
+
export function SmsPreview(props) {
|
|
9
|
+
const {
|
|
10
|
+
senderName,
|
|
11
|
+
channelName,
|
|
12
|
+
text,
|
|
13
|
+
emptyText,
|
|
14
|
+
segments
|
|
15
|
+
} = props;
|
|
16
|
+
return _jsxs(Vertical, {
|
|
17
|
+
"$gap": 8,
|
|
18
|
+
"$alignContent": "start",
|
|
19
|
+
children: [_jsxs(Phone, {
|
|
20
|
+
children: [_jsxs(PhoneHeader, {
|
|
21
|
+
children: [_jsx(Text, {
|
|
22
|
+
"$variant": "h4",
|
|
23
|
+
children: senderName
|
|
24
|
+
}), _jsx(Text, {
|
|
25
|
+
"$color": Color.LOCKED,
|
|
26
|
+
children: channelName || _jsx(Lang, {
|
|
27
|
+
message: "DUMB.SMS_PREVIEW.CHANNEL"
|
|
28
|
+
})
|
|
29
|
+
})]
|
|
30
|
+
}), _jsx(Thread, {
|
|
31
|
+
children: text ? _jsx(Bubble, {
|
|
32
|
+
children: text
|
|
33
|
+
}) : _jsx(Placeholder, {
|
|
34
|
+
children: emptyText || _jsx(Lang, {
|
|
35
|
+
message: "DUMB.SMS_PREVIEW.EMPTY"
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
})]
|
|
39
|
+
}), text && segments && _jsx(Text, {
|
|
40
|
+
"$color": Color.LOCKED,
|
|
41
|
+
children: _jsx(Lang, {
|
|
42
|
+
message: "DUMB.SMS_PREVIEW.SEGMENTS",
|
|
43
|
+
segments: segments.count,
|
|
44
|
+
encoding: segments.encoding === 'GSM7' ? 'GSM-7' : 'Unicode'
|
|
45
|
+
})
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SmsPreview } from './SmsPreview';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { messages as ar } from './messages_ar';
|
|
2
|
+
import { messages as bn } from './messages_bn';
|
|
3
|
+
import { messages as de } from './messages_de';
|
|
4
|
+
import { messages as en } from './messages_en';
|
|
5
|
+
import { messages as es } from './messages_es';
|
|
6
|
+
import { messages as fr } from './messages_fr';
|
|
7
|
+
import { messages as he } from './messages_he';
|
|
8
|
+
import { messages as hi } from './messages_hi';
|
|
9
|
+
import { messages as ja } from './messages_ja';
|
|
10
|
+
import { messages as ko } from './messages_ko';
|
|
11
|
+
import { messages as pt } from './messages_pt';
|
|
12
|
+
import { messages as ru } from './messages_ru';
|
|
13
|
+
import { messages as th } from './messages_th';
|
|
14
|
+
import { messages as zh } from './messages_zh';
|
|
15
|
+
import { createLang } from '../../polyglot';
|
|
16
|
+
export const {
|
|
17
|
+
Lang,
|
|
18
|
+
useLang
|
|
19
|
+
} = createLang({
|
|
20
|
+
ar,
|
|
21
|
+
bn,
|
|
22
|
+
de,
|
|
23
|
+
en,
|
|
24
|
+
es,
|
|
25
|
+
fr,
|
|
26
|
+
he,
|
|
27
|
+
hi,
|
|
28
|
+
ja,
|
|
29
|
+
ko,
|
|
30
|
+
pt,
|
|
31
|
+
ru,
|
|
32
|
+
th,
|
|
33
|
+
zh
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const Phone: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
2
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
3
|
+
}> & string;
|
|
4
|
+
export declare const PhoneHeader: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
5
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
6
|
+
}> & string;
|
|
7
|
+
export declare const Thread: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
8
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
9
|
+
}> & string;
|
|
10
|
+
export declare const Bubble: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
11
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
12
|
+
}> & string;
|
|
13
|
+
export declare const Placeholder: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
14
|
+
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
15
|
+
}> & string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color, FontSize, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
3
|
+
export const Phone = styled.div.withConfig({
|
|
4
|
+
displayName: "Phone",
|
|
5
|
+
componentId: "sc-1wraspo-0"
|
|
6
|
+
})(["width:320px;border:8px solid ", ";border-radius:32px;overflow:hidden;background-color:", ";"], Color.MAIN, Color.CLEAR);
|
|
7
|
+
export const PhoneHeader = styled.div.withConfig({
|
|
8
|
+
displayName: "PhoneHeader",
|
|
9
|
+
componentId: "sc-1wraspo-1"
|
|
10
|
+
})(["display:flex;flex-direction:column;gap:2px;padding:12px;border-bottom:1px solid ", ";text-align:center;"], Color.DIVIDER);
|
|
11
|
+
export const Thread = styled.div.withConfig({
|
|
12
|
+
displayName: "Thread",
|
|
13
|
+
componentId: "sc-1wraspo-2"
|
|
14
|
+
})(["display:flex;flex-direction:column;min-height:160px;padding:16px 12px;"]);
|
|
15
|
+
export const Bubble = styled.div.withConfig({
|
|
16
|
+
displayName: "Bubble",
|
|
17
|
+
componentId: "sc-1wraspo-3"
|
|
18
|
+
})(["padding:10px 12px;border-radius:16px 16px 16px 4px;background-color:", ";color:", ";font-size:", ";line-height:1.4;white-space:pre-wrap;word-break:break-word;unicode-bidi:plaintext;text-align:start;"], Color.DIVIDER, Color.MAIN, FontSize.REGULAR);
|
|
19
|
+
export const Placeholder = styled.div.withConfig({
|
|
20
|
+
displayName: "Placeholder",
|
|
21
|
+
componentId: "sc-1wraspo-4"
|
|
22
|
+
})(["padding:12px;border:1px dashed ", ";border-radius:", ";color:", ";font-size:", ";text-align:center;"], Color.FORM, ShapeRadius.SECTION, Color.LOCKED, FontSize.SMALL);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Character set the message is sent in; it sets the segment size. */
|
|
2
|
+
export type SmsEncoding = 'GSM7' | 'UCS2';
|
|
3
|
+
/** How many SMS parts the text is split into on the wire. */
|
|
4
|
+
export interface SmsSegments {
|
|
5
|
+
/** Number of parts. */
|
|
6
|
+
count: number;
|
|
7
|
+
/** Character set of the parts. */
|
|
8
|
+
encoding: SmsEncoding;
|
|
9
|
+
}
|
|
10
|
+
/** Props of {@link SmsPreview}. */
|
|
11
|
+
export interface SmsPreviewProps {
|
|
12
|
+
/** Who the message comes from: the application title, or the sender name of a messenger. */
|
|
13
|
+
senderName: string;
|
|
14
|
+
/** Channel line under the sender; `SMS` by default. */
|
|
15
|
+
channelName?: string;
|
|
16
|
+
/** Message text, shown in one bubble. */
|
|
17
|
+
text: string;
|
|
18
|
+
/** Shown instead of the bubble when `text` is empty. */
|
|
19
|
+
emptyText?: string;
|
|
20
|
+
/** Segment line under the phone; hidden when absent or when `text` is empty. */
|
|
21
|
+
segments?: SmsSegments;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/Tooltip/Tooltip.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { TooltipProps } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* Wraps an element and shows a contextual tooltip on hover/focus, with configurable
|
|
4
|
+
* Wraps an element and shows a contextual tooltip on hover/keyboard focus, with configurable
|
|
5
5
|
* position, width and color. Positioning is handled by floating-ui, so the tooltip
|
|
6
6
|
* flips to a fallback placement when the requested one would overflow the viewport. Use
|
|
7
7
|
* {@link TooltipTrigger} for a standalone help icon.
|
package/Tooltip/Tooltip.js
CHANGED
|
@@ -6,7 +6,7 @@ import { DEFAULT_MAX_WIDTH } from './constants';
|
|
|
6
6
|
import { Arrow, TooltipBox } from './styles';
|
|
7
7
|
import { useTooltipPosition } from './useTooltipPosition';
|
|
8
8
|
/**
|
|
9
|
-
* Wraps an element and shows a contextual tooltip on hover/focus, with configurable
|
|
9
|
+
* Wraps an element and shows a contextual tooltip on hover/keyboard focus, with configurable
|
|
10
10
|
* position, width and color. Positioning is handled by floating-ui, so the tooltip
|
|
11
11
|
* flips to a fallback placement when the requested one would overflow the viewport. Use
|
|
12
12
|
* {@link TooltipTrigger} for a standalone help icon.
|
|
@@ -70,14 +70,19 @@ export function Tooltip({
|
|
|
70
70
|
}
|
|
71
71
|
const show = () => setIsHovered(true);
|
|
72
72
|
const hide = () => setIsHovered(false);
|
|
73
|
+
const showOnKeyboardFocus = event => {
|
|
74
|
+
if (event.target instanceof Element && event.target.matches(':focus-visible')) {
|
|
75
|
+
show();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
73
78
|
referenceEl.addEventListener('mouseenter', show);
|
|
74
79
|
referenceEl.addEventListener('mouseleave', hide);
|
|
75
|
-
referenceEl.addEventListener('focusin',
|
|
80
|
+
referenceEl.addEventListener('focusin', showOnKeyboardFocus);
|
|
76
81
|
referenceEl.addEventListener('focusout', hide);
|
|
77
82
|
return () => {
|
|
78
83
|
referenceEl.removeEventListener('mouseenter', show);
|
|
79
84
|
referenceEl.removeEventListener('mouseleave', hide);
|
|
80
|
-
referenceEl.removeEventListener('focusin',
|
|
85
|
+
referenceEl.removeEventListener('focusin', showOnKeyboardFocus);
|
|
81
86
|
referenceEl.removeEventListener('focusout', hide);
|
|
82
87
|
};
|
|
83
88
|
}, [referenceEl, isControlled]);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import { type WalletPassPreviewProps } from './types';
|
|
3
|
+
/** Renders an Apple Wallet pass with its status, back fields and the preview caveats. */
|
|
4
|
+
export declare function WalletPassPreview({ pass, passStyle, imageUrls, }: WalletPassPreviewProps): ReactElement;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { BarcodePlaceholder } from './components/BarcodePlaceholder';
|
|
4
|
+
import { BACK_FIELDS_SHOWN, BARCODE_NAMES, STYLE_NAMES, TRANSIT_ICONS } from './constants';
|
|
5
|
+
import { formatFieldValue, parseRgbColor } from './helpers';
|
|
6
|
+
import { Lang, useLang } from './polyglot';
|
|
7
|
+
import { AuxiliaryField, AuxiliaryFields, BackFieldItem, BackFieldLabel, BackFieldMore, BackFields, Background, Barcode, BarcodeAltText, Card, Content, CoverImage, FieldLabel, FieldValue, FieldValueSecondary, FieldValueSmall, Footer, FooterImage, Header, HeaderBrand, HeaderField, HeaderFields, Info, InfoBadge, InfoBar, InfoSection, Logo, LogoText, Note, PrimaryField, PrimaryFields, SecondaryField, SecondaryFields, SectionTitle, SerialItem, SerialLabel, StatusBadge, Strip, Thumbnail } from './styles';
|
|
8
|
+
/** Renders an Apple Wallet pass with its status, back fields and the preview caveats. */
|
|
9
|
+
export function WalletPassPreview({
|
|
10
|
+
pass,
|
|
11
|
+
passStyle,
|
|
12
|
+
imageUrls = {}
|
|
13
|
+
}) {
|
|
14
|
+
const lang = useLang();
|
|
15
|
+
const bgColor = parseRgbColor(pass.backgroundColor);
|
|
16
|
+
const fgColor = parseRgbColor(pass.foregroundColor);
|
|
17
|
+
const labelColor = parseRgbColor(pass.labelColor);
|
|
18
|
+
const transitType = pass.boardingPass?.transitType;
|
|
19
|
+
const barcodeFormat = pass.barcodes?.[0]?.format || 'PKBarcodeFormatQR';
|
|
20
|
+
const styleBlock = pass[passStyle];
|
|
21
|
+
const isBoarding = passStyle === 'boardingPass';
|
|
22
|
+
return _jsxs("div", {
|
|
23
|
+
children: [_jsxs(Card, {
|
|
24
|
+
"$bg": bgColor,
|
|
25
|
+
"$fg": fgColor,
|
|
26
|
+
children: [_jsxs(Header, {
|
|
27
|
+
children: [_jsxs(HeaderBrand, {
|
|
28
|
+
children: [imageUrls.logo && _jsx(Logo, {
|
|
29
|
+
src: imageUrls.logo,
|
|
30
|
+
alt: lang({
|
|
31
|
+
message: 'DUMB.WALLET_PASS_PREVIEW.IMAGE_LOGO'
|
|
32
|
+
})
|
|
33
|
+
}), !imageUrls.logo && pass.logoText && _jsx(LogoText, {
|
|
34
|
+
children: pass.logoText
|
|
35
|
+
})]
|
|
36
|
+
}), styleBlock?.headerFields && styleBlock.headerFields.length > 0 && _jsx(HeaderFields, {
|
|
37
|
+
children: styleBlock.headerFields.map((field, i) => _jsxs(HeaderField, {
|
|
38
|
+
children: [field.label && _jsx(FieldLabel, {
|
|
39
|
+
"$color": labelColor,
|
|
40
|
+
children: field.label
|
|
41
|
+
}), _jsx(FieldValueSmall, {
|
|
42
|
+
children: formatFieldValue(field)
|
|
43
|
+
})]
|
|
44
|
+
}, `${field.key ?? 'header'}-${i}`))
|
|
45
|
+
})]
|
|
46
|
+
}), imageUrls.strip && _jsx(Strip, {
|
|
47
|
+
children: _jsx(CoverImage, {
|
|
48
|
+
src: imageUrls.strip,
|
|
49
|
+
alt: lang({
|
|
50
|
+
message: 'DUMB.WALLET_PASS_PREVIEW.IMAGE_STRIP'
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
}), imageUrls.background && _jsx(Background, {
|
|
54
|
+
children: _jsx(CoverImage, {
|
|
55
|
+
src: imageUrls.background,
|
|
56
|
+
alt: lang({
|
|
57
|
+
message: 'DUMB.WALLET_PASS_PREVIEW.IMAGE_BACKGROUND'
|
|
58
|
+
})
|
|
59
|
+
})
|
|
60
|
+
}), _jsxs(Content, {
|
|
61
|
+
children: [styleBlock?.primaryFields && styleBlock.primaryFields.length > 0 && _jsxs(PrimaryFields, {
|
|
62
|
+
"$boarding": isBoarding,
|
|
63
|
+
children: [styleBlock.primaryFields.map((field, i) => _jsxs(PrimaryField, {
|
|
64
|
+
"$boarding": isBoarding,
|
|
65
|
+
children: [field.label && _jsx(FieldLabel, {
|
|
66
|
+
"$color": labelColor,
|
|
67
|
+
children: field.label
|
|
68
|
+
}), _jsx(FieldValue, {
|
|
69
|
+
children: formatFieldValue(field)
|
|
70
|
+
})]
|
|
71
|
+
}, `${field.key ?? 'primary'}-${i}`)), imageUrls.thumbnail && (passStyle === 'eventTicket' || passStyle === 'generic') && _jsx(Thumbnail, {
|
|
72
|
+
src: imageUrls.thumbnail,
|
|
73
|
+
alt: lang({
|
|
74
|
+
message: 'DUMB.WALLET_PASS_PREVIEW.IMAGE_THUMBNAIL'
|
|
75
|
+
})
|
|
76
|
+
})]
|
|
77
|
+
}), styleBlock?.auxiliaryFields && styleBlock.auxiliaryFields.length > 0 && _jsx(AuxiliaryFields, {
|
|
78
|
+
children: styleBlock.auxiliaryFields.map((field, i) => _jsxs(AuxiliaryField, {
|
|
79
|
+
children: [field.label && _jsx(FieldLabel, {
|
|
80
|
+
"$color": labelColor,
|
|
81
|
+
children: field.label
|
|
82
|
+
}), _jsx(FieldValueSmall, {
|
|
83
|
+
children: formatFieldValue(field)
|
|
84
|
+
})]
|
|
85
|
+
}, `${field.key ?? 'auxiliary'}-${i}`))
|
|
86
|
+
}), styleBlock?.secondaryFields && styleBlock.secondaryFields.length > 0 && _jsx(SecondaryFields, {
|
|
87
|
+
children: styleBlock.secondaryFields.map((field, i) => _jsxs(SecondaryField, {
|
|
88
|
+
children: [field.label && _jsx(FieldLabel, {
|
|
89
|
+
"$color": labelColor,
|
|
90
|
+
children: field.label
|
|
91
|
+
}), _jsx(FieldValueSecondary, {
|
|
92
|
+
children: formatFieldValue(field)
|
|
93
|
+
})]
|
|
94
|
+
}, `${field.key ?? 'secondary'}-${i}`))
|
|
95
|
+
})]
|
|
96
|
+
}), pass.barcodes && pass.barcodes[0] && _jsxs(Barcode, {
|
|
97
|
+
children: [_jsx(BarcodePlaceholder, {
|
|
98
|
+
format: barcodeFormat
|
|
99
|
+
}), _jsx(BarcodeAltText, {
|
|
100
|
+
"$color": labelColor,
|
|
101
|
+
children: pass.barcodes[0].altText || pass.barcodes[0].message
|
|
102
|
+
})]
|
|
103
|
+
}), imageUrls.footer && _jsx(Footer, {
|
|
104
|
+
children: _jsx(FooterImage, {
|
|
105
|
+
src: imageUrls.footer,
|
|
106
|
+
alt: lang({
|
|
107
|
+
message: 'DUMB.WALLET_PASS_PREVIEW.IMAGE_FOOTER'
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
})]
|
|
111
|
+
}), _jsxs(InfoBar, {
|
|
112
|
+
children: [_jsx(InfoBadge, {
|
|
113
|
+
"$background": Color.PRIMARY,
|
|
114
|
+
"$capitalize": true,
|
|
115
|
+
children: STYLE_NAMES[passStyle] ? lang({
|
|
116
|
+
message: STYLE_NAMES[passStyle]
|
|
117
|
+
}) : passStyle
|
|
118
|
+
}), isBoarding && transitType && _jsx(InfoBadge, {
|
|
119
|
+
"$background": Color.SUCCESS,
|
|
120
|
+
children: TRANSIT_ICONS[transitType] ? lang({
|
|
121
|
+
message: TRANSIT_ICONS[transitType]
|
|
122
|
+
}) : transitType.replace('PKTransitType', '')
|
|
123
|
+
}), pass.barcodes?.[0] && _jsx(InfoBadge, {
|
|
124
|
+
"$background": Color.WARNING,
|
|
125
|
+
children: BARCODE_NAMES[barcodeFormat] || _jsx(Lang, {
|
|
126
|
+
message: "DUMB.WALLET_PASS_PREVIEW.BARCODE_QR"
|
|
127
|
+
})
|
|
128
|
+
})]
|
|
129
|
+
}), _jsxs(Info, {
|
|
130
|
+
children: [(pass.serialNumber || pass.voided || pass.expirationDate || pass.relevantDate || pass.locations && pass.locations.length > 0) && _jsxs(InfoSection, {
|
|
131
|
+
children: [_jsx(SectionTitle, {
|
|
132
|
+
children: _jsx(Lang, {
|
|
133
|
+
message: "DUMB.WALLET_PASS_PREVIEW.STATUS_SECTION"
|
|
134
|
+
})
|
|
135
|
+
}), pass.serialNumber && _jsxs(SerialItem, {
|
|
136
|
+
children: [_jsx(SerialLabel, {
|
|
137
|
+
children: _jsx(Lang, {
|
|
138
|
+
message: "DUMB.WALLET_PASS_PREVIEW.SERIAL"
|
|
139
|
+
})
|
|
140
|
+
}), ' ', pass.serialNumber]
|
|
141
|
+
}), pass.voided && _jsx(StatusBadge, {
|
|
142
|
+
"$background": Color.DANGER,
|
|
143
|
+
"$bold": true,
|
|
144
|
+
children: _jsx(Lang, {
|
|
145
|
+
message: "DUMB.WALLET_PASS_PREVIEW.VOIDED"
|
|
146
|
+
})
|
|
147
|
+
}), pass.expirationDate && _jsx(StatusBadge, {
|
|
148
|
+
"$background": Color.WARNING,
|
|
149
|
+
children: _jsx(Lang, {
|
|
150
|
+
message: "DUMB.WALLET_PASS_PREVIEW.EXPIRES",
|
|
151
|
+
date: new Date(pass.expirationDate).toLocaleDateString()
|
|
152
|
+
})
|
|
153
|
+
}), pass.relevantDate && _jsx(StatusBadge, {
|
|
154
|
+
"$background": Color.PRIMARY,
|
|
155
|
+
children: _jsx(Lang, {
|
|
156
|
+
message: "DUMB.WALLET_PASS_PREVIEW.LOCK_SCREEN",
|
|
157
|
+
date: new Date(pass.relevantDate).toLocaleString()
|
|
158
|
+
})
|
|
159
|
+
}), pass.locations && pass.locations.length > 0 && _jsx(StatusBadge, {
|
|
160
|
+
"$background": Color.SUCCESS,
|
|
161
|
+
children: _jsx(Lang, {
|
|
162
|
+
message: "DUMB.WALLET_PASS_PREVIEW.LOCATIONS",
|
|
163
|
+
count: pass.locations.length
|
|
164
|
+
})
|
|
165
|
+
}), pass.maxDistance ? _jsx(StatusBadge, {
|
|
166
|
+
"$background": Color.EXCEPTIONAL,
|
|
167
|
+
children: _jsx(Lang, {
|
|
168
|
+
message: "DUMB.WALLET_PASS_PREVIEW.MAX_DISTANCE",
|
|
169
|
+
distance: pass.maxDistance
|
|
170
|
+
})
|
|
171
|
+
}) : null]
|
|
172
|
+
}), styleBlock?.backFields && styleBlock.backFields.length > 0 && _jsxs(InfoSection, {
|
|
173
|
+
children: [_jsx(SectionTitle, {
|
|
174
|
+
children: _jsx(Lang, {
|
|
175
|
+
message: "DUMB.WALLET_PASS_PREVIEW.BACK_FIELDS",
|
|
176
|
+
count: styleBlock.backFields.length
|
|
177
|
+
})
|
|
178
|
+
}), _jsxs(BackFields, {
|
|
179
|
+
children: [styleBlock.backFields.slice(0, BACK_FIELDS_SHOWN).map((field, i) => _jsxs(BackFieldItem, {
|
|
180
|
+
children: [_jsxs(BackFieldLabel, {
|
|
181
|
+
children: [field.label || field.key, ":"]
|
|
182
|
+
}), ' ', formatFieldValue(field)]
|
|
183
|
+
}, `${field.key ?? 'back'}-${i}`)), styleBlock.backFields.length > BACK_FIELDS_SHOWN && _jsx(BackFieldMore, {
|
|
184
|
+
children: _jsx(Lang, {
|
|
185
|
+
message: "DUMB.WALLET_PASS_PREVIEW.MORE",
|
|
186
|
+
count: styleBlock.backFields.length - BACK_FIELDS_SHOWN
|
|
187
|
+
})
|
|
188
|
+
})]
|
|
189
|
+
})]
|
|
190
|
+
})]
|
|
191
|
+
}), _jsxs(Note, {
|
|
192
|
+
children: [_jsx(Lang, {
|
|
193
|
+
message: "DUMB.WALLET_PASS_PREVIEW.NOTE_SIMPLIFIED"
|
|
194
|
+
}), _jsx("br", {}), _jsx("strong", {
|
|
195
|
+
children: _jsx(Lang, {
|
|
196
|
+
message: "DUMB.WALLET_PASS_PREVIEW.NOTE_LABEL"
|
|
197
|
+
})
|
|
198
|
+
}), ' ', _jsx(Lang, {
|
|
199
|
+
message: "DUMB.WALLET_PASS_PREVIEW.NOTE_BARCODES"
|
|
200
|
+
})]
|
|
201
|
+
})]
|
|
202
|
+
});
|
|
203
|
+
}
|