@popsure/dirty-swan 0.38.3 → 0.38.4
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/dist/cjs/index.js +26 -1890
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/autocompleteAddress/index.d.ts +18 -1
- package/dist/cjs/lib/components/autocompleteAddress/index.stories.d.ts +1 -1
- package/dist/esm/components/autocompleteAddress/index.js +24 -1888
- package/dist/esm/components/autocompleteAddress/index.js.map +1 -1
- package/dist/esm/components/autocompleteAddress/index.stories.js +14 -14
- package/dist/esm/components/autocompleteAddress/index.stories.js.map +1 -1
- package/dist/esm/components/cards/index.js +3 -3
- package/dist/esm/components/cards/index.js.map +1 -1
- package/dist/esm/lib/components/autocompleteAddress/index.d.ts +18 -1
- package/dist/esm/lib/components/autocompleteAddress/index.stories.d.ts +1 -1
- package/package.json +1 -1
- package/src/lib/components/autocompleteAddress/index.stories.tsx +41 -33
- package/src/lib/components/autocompleteAddress/index.tsx +55 -53
- package/src/lib/components/cards/cardWithLeftIcon/index.tsx +4 -6
- package/src/lib/components/cards/cardWithTopLeftIcon/index.tsx +6 -8
|
@@ -17,7 +17,7 @@ var story = {
|
|
|
17
17
|
description: 'The address properties',
|
|
18
18
|
table: {
|
|
19
19
|
type: {
|
|
20
|
-
summary: 'Partial<Address>'
|
|
20
|
+
summary: 'Partial<Address>',
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
},
|
|
@@ -26,7 +26,7 @@ var story = {
|
|
|
26
26
|
description: 'Your private API key for the [Google Places API](https://developers.google.com/maps/documentation/places/web-service/overview)',
|
|
27
27
|
table: {
|
|
28
28
|
type: {
|
|
29
|
-
summary: 'Partial<Address>'
|
|
29
|
+
summary: 'Partial<Address>',
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
},
|
|
@@ -34,25 +34,25 @@ var story = {
|
|
|
34
34
|
description: 'Callback with the updated address, this function will get called everytime the address gets updated',
|
|
35
35
|
action: true,
|
|
36
36
|
table: {
|
|
37
|
-
category:
|
|
37
|
+
category: 'Callbacks',
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
manualAddressEntryTexts: {
|
|
41
41
|
description: 'The CTA that enables manual address entry and the text preceding it',
|
|
42
42
|
table: {
|
|
43
43
|
type: {
|
|
44
|
-
summary: '{ preText?: string; cta: string?; }'
|
|
45
|
-
}
|
|
46
|
-
}
|
|
44
|
+
summary: '{ preText?: string; cta: string?; }',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
47
|
},
|
|
48
48
|
placeholders: {
|
|
49
49
|
description: 'Placeholder text',
|
|
50
50
|
table: {
|
|
51
51
|
type: {
|
|
52
|
-
summary: '{ manualAddressEntry?: string; street: string?; houseNumber?: string; additionalInformation?: string; postcode?: string; city?: string; }'
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
52
|
+
summary: '{ manualAddressEntry?: string; street: string?; houseNumber?: string; additionalInformation?: string; postcode?: string; city?: string; }',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
56
|
},
|
|
57
57
|
parameters: {
|
|
58
58
|
componentSubtitle: 'Autocomplete Address are user interface elements which allow users start typing an address and get autocompletion suggestions on the address.',
|
|
@@ -62,20 +62,20 @@ var story = {
|
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
customTypes: {
|
|
65
|
-
Address: "interface Address {\n street: string;\n houseNumber: string;\n postcode: string;\n city: string;\n additionalInformation?: string;\n country: string;\n }"
|
|
66
|
-
}
|
|
65
|
+
Address: "interface Address {\n street: string;\n houseNumber: string;\n postcode: string;\n city: string;\n additionalInformation?: string;\n country: string;\n }",
|
|
66
|
+
},
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
69
|
var AutocompleteAddressStory = function (_a) {
|
|
70
70
|
var defaultAddress = _a.address, apiKey = _a.apiKey, manualAddressEntryTexts = _a.manualAddressEntryTexts, onAddressChange = _a.onAddressChange, placeholders = _a.placeholders;
|
|
71
71
|
var _b = useState(defaultAddress), address = _b[0], setAddress = _b[1];
|
|
72
72
|
var handleOnAddressChange = function (newAddress) {
|
|
73
|
-
onAddressChange(newAddress);
|
|
73
|
+
onAddressChange === null || onAddressChange === void 0 ? void 0 : onAddressChange(newAddress);
|
|
74
74
|
setAddress(newAddress);
|
|
75
75
|
};
|
|
76
76
|
return (jsx(AutocompleteAddress, { address: address, apiKey: apiKey, manualAddressEntryTexts: manualAddressEntryTexts, onAddressChange: handleOnAddressChange, placeholders: placeholders }, void 0));
|
|
77
77
|
};
|
|
78
|
-
AutocompleteAddressStory.storyName =
|
|
78
|
+
AutocompleteAddressStory.storyName = 'AutocompleteAddress';
|
|
79
79
|
var WithAddress = function (_a) {
|
|
80
80
|
var apiKey = _a.apiKey, onAddressChange = _a.onAddressChange; _a.placeholders;
|
|
81
81
|
return (jsx(AutocompleteAddress, { address: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.stories.js","sources":["../../../../../src/lib/components/autocompleteAddress/index.stories.tsx"],"sourcesContent":["import { Address } from '@popsure/public-models';\nimport { useState } from 'react';\nimport { AutocompleteAddress, AutocompleteAddressProps } from '.';\n\nconst story = {\n title: 'JSX/AutocompleteAddress',\n component: AutocompleteAddress,\n argTypes: {\n address: {\n description: 'The address properties',\n table: {\n type: {
|
|
1
|
+
{"version":3,"file":"index.stories.js","sources":["../../../../../src/lib/components/autocompleteAddress/index.stories.tsx"],"sourcesContent":["import { Address } from '@popsure/public-models';\nimport { useState } from 'react';\nimport { AutocompleteAddress, AutocompleteAddressProps } from '.';\n\nconst story = {\n title: 'JSX/AutocompleteAddress',\n component: AutocompleteAddress,\n argTypes: {\n address: {\n description: 'The address properties',\n table: {\n type: {\n summary: 'Partial<Address>',\n },\n },\n },\n apiKey: {\n defaultValue: 'AIzaSyDg0DSrjYKt5smmsjkVasDz7c4T5rbOXT8',\n description:\n 'Your private API key for the [Google Places API](https://developers.google.com/maps/documentation/places/web-service/overview)',\n table: {\n type: {\n summary: 'Partial<Address>',\n },\n },\n },\n onAddressChange: {\n description:\n 'Callback with the updated address, this function will get called everytime the address gets updated',\n action: true,\n table: {\n category: 'Callbacks',\n },\n },\n manualAddressEntryTexts: {\n description:\n 'The CTA that enables manual address entry and the text preceding it',\n table: {\n type: {\n summary: '{ preText?: string; cta: string?; }',\n },\n },\n },\n placeholders: {\n description: 'Placeholder text',\n table: {\n type: {\n summary:\n '{ manualAddressEntry?: string; street: string?; houseNumber?: string; additionalInformation?: string; postcode?: string; city?: string; }',\n },\n },\n },\n },\n parameters: {\n componentSubtitle:\n 'Autocomplete Address are user interface elements which allow users start typing an address and get autocompletion suggestions on the address.',\n docs: {\n description: {\n component:\n 'This component is for now only restricted to \"address\" types and will restrict every query to Germany.',\n },\n },\n customTypes: {\n Address: `interface Address {\n street: string;\n houseNumber: string;\n postcode: string;\n city: string;\n additionalInformation?: string;\n country: string;\n }`,\n },\n },\n};\n\nexport const AutocompleteAddressStory = ({\n address: defaultAddress,\n apiKey,\n manualAddressEntryTexts,\n onAddressChange,\n placeholders,\n}: AutocompleteAddressProps) => {\n const [address, setAddress] = useState<Partial<Address> | undefined>(\n defaultAddress\n );\n const handleOnAddressChange = (newAddress: Partial<Address>) => {\n onAddressChange?.(newAddress);\n setAddress(newAddress);\n };\n\n return (\n <AutocompleteAddress\n address={address}\n apiKey={apiKey}\n manualAddressEntryTexts={manualAddressEntryTexts}\n onAddressChange={handleOnAddressChange}\n placeholders={placeholders}\n />\n );\n};\n\nAutocompleteAddressStory.storyName = 'AutocompleteAddress';\n\nexport const WithAddress = ({\n apiKey,\n onAddressChange,\n placeholders,\n}: AutocompleteAddressProps) => (\n <AutocompleteAddress\n address={{\n street: 'Lohmuehlenstraße',\n houseNumber: '65',\n city: 'Berlin',\n country: 'DE',\n additionalInformation: 'c/o Factory',\n }}\n apiKey={apiKey}\n onAddressChange={onAddressChange}\n />\n);\n\nexport const WithLocalisationEntryText = ({\n apiKey,\n onAddressChange,\n}: AutocompleteAddressProps) => (\n <AutocompleteAddress\n apiKey={apiKey}\n manualAddressEntryTexts={{\n preText: 'Oder ',\n cta: 'Adresse direkt eingeben',\n }}\n onAddressChange={onAddressChange}\n />\n);\n\nexport const WithLocalisationPlaceholders = ({\n apiKey,\n onAddressChange,\n}: AutocompleteAddressProps) => (\n <AutocompleteAddress\n address={{}}\n apiKey={apiKey}\n placeholders={{\n manualAddressEntry: 'Adresse suchen',\n street: 'Straße',\n houseNumber: 'Hausnummer',\n additionalInformation: 'Adresszusatz (c/o, z.Hd., o.V.i.A, ...)',\n postcode: 'PLZ',\n city: 'Stadt',\n }}\n onAddressChange={onAddressChange}\n />\n);\n\nexport default story;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;IAIM,KAAK,GAAG;IACZ,KAAK,EAAE,yBAAyB;IAChC,SAAS,EAAE,mBAAmB;IAC9B,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,WAAW,EAAE,wBAAwB;YACrC,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,OAAO,EAAE,kBAAkB;iBAC5B;aACF;SACF;QACD,MAAM,EAAE;YACN,YAAY,EAAE,yCAAyC;YACvD,WAAW,EACT,gIAAgI;YAClI,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,OAAO,EAAE,kBAAkB;iBAC5B;aACF;SACF;QACD,eAAe,EAAE;YACf,WAAW,EACT,qGAAqG;YACvG,MAAM,EAAE,IAAI;YACZ,KAAK,EAAE;gBACL,QAAQ,EAAE,WAAW;aACtB;SACF;QACD,uBAAuB,EAAE;YACvB,WAAW,EACT,qEAAqE;YACvE,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,OAAO,EAAE,qCAAqC;iBAC/C;aACF;SACF;QACD,YAAY,EAAE;YACZ,WAAW,EAAE,kBAAkB;YAC/B,KAAK,EAAE;gBACL,IAAI,EAAE;oBACJ,OAAO,EACL,2IAA2I;iBAC9I;aACF;SACF;KACF;IACD,UAAU,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AG,EAAE,yBAAyB;SAC/B,EACD,eAAe,EAAE,eAAe,WAChC;AAR4B,EAS9B;IAEW,4BAA4B,GAAG,UAAC,EAGlB;QAFzB,MAAM,YAAA,EACN,eAAe,qBAAA;IACe,QAC9BA,IAAC,mBAAmB,IAClB,OAAO,EAAE,EAAE,EACX,MAAM,EAAE,MAAM,EACd,YAAY,EAAE;YACZ,kBAAkB,EAAE,gBAAgB;YACpC,MAAM,EAAE,QAAQ;YAChB,WAAW,EAAE,YAAY;YACzB,qBAAqB,EAAE,yCAAyC;YAChE,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,OAAO;SACd,EACD,eAAe,EAAE,eAAe,WAChC;AAb4B;;;;;"}
|
|
@@ -28,7 +28,7 @@ var CardWithTopLeftIcon = function (_a) {
|
|
|
28
28
|
return (jsxs("div", __assign({ className: cardStyle }, props, { children: [jsxs("div", __assign({ className: titleContainerStyle }, { children: [leftIcon && (jsx("img", { className: "mr8", width: "28px", height: "28px", src: leftIcon === 'logo' ? featherLogo.src : leftIcon.src, alt: leftIcon === 'logo' ? featherLogo.alt : leftIcon.src }, void 0)),
|
|
29
29
|
jsx("div", __assign({ className: headingStyle }, { children: title }), void 0),
|
|
30
30
|
rightIcon && (jsx("img", { className: iconStyle, width: "24px", height: "24px", src: rightIcon === 'arrow' ? arrowRight.src : rightIcon.src, alt: rightIcon === 'arrow' ? arrowRight.alt : rightIcon.alt }, void 0))] }), void 0),
|
|
31
|
-
jsx("
|
|
31
|
+
jsx("div", __assign({ className: cardTextStyle }, { children: children }), void 0)] }), void 0));
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
var css_248z$2 = ".style-module_container__34kUF {\n padding: 32px 24px 24px 24px;\n display: flex;\n flex-direction: column;\n align-items: center;\n}\n\n.style-module_right-icon__3_kH9 {\n margin-left: 4px;\n}";
|
|
@@ -117,10 +117,10 @@ var CardWithLeftIcon = function (_a) {
|
|
|
117
117
|
var iconStyle = cardSize === 'xsmall' ? 'mr16' : 'mr32';
|
|
118
118
|
var cardTextStyle = "tc-grey-600 " + (cardSize === 'xsmall' ? 'p-p--small' : 'p-p ') + " " + styles[cardTextStyleFromCardSize(cardSize)];
|
|
119
119
|
return (jsxs("div", __assign({ className: cardStyle }, props, { children: [leftIcon && (jsx("img", { width: ((leftIconSize === null || leftIconSize === void 0 ? void 0 : leftIconSize.width) || 48) + "px", height: ((leftIconSize === null || leftIconSize === void 0 ? void 0 : leftIconSize.height) || 48) + "px", className: iconStyle, src: leftIcon.src, alt: leftIcon.alt }, void 0)),
|
|
120
|
-
jsxs("div", { children: [jsxs("div", __assign({ className: "d-flex" }, { children: [(title || subtitle) && (jsxs("div", { children: [title &&
|
|
120
|
+
jsxs("div", { children: [jsxs("div", __assign({ className: "d-flex" }, { children: [(title || subtitle) && (jsxs("div", { children: [title && jsx("div", __assign({ className: headingStyle }, { children: title }), void 0),
|
|
121
121
|
subtitle && (jsx("div", __assign({ className: "tc-grey-500 " + headingStyle }, { children: subtitle }), void 0))] }, void 0)),
|
|
122
122
|
rightIcon && (jsx("img", { className: "ml-auto", width: "24px", height: "24px", src: rightIcon === 'arrow' ? arrowRight.src : rightIcon.src, alt: rightIcon === 'arrow' ? arrowRight.alt : rightIcon.alt }, void 0))] }), void 0),
|
|
123
|
-
jsx("
|
|
123
|
+
jsx("div", __assign({ className: cardTextStyle }, { children: children }), void 0)] }, void 0)] }), void 0));
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
export { CardWithLeftIcon, CardWithTopIcon, CardWithTopLeftIcon, InfoCard, associatedClassForCardState, headingForCardSize };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/lib/components/cards/cardWithTopLeftIcon/index.tsx","../../../../../src/lib/components/cards/cardWithTopIcon/index.tsx","../../../../../src/lib/components/cards/infoCard/index.tsx","../../../../../src/lib/components/cards/index.tsx","../../../../../src/lib/components/cards/cardWithLeftIcon/index.tsx"],"sourcesContent":["import {\n associatedClassForCardState,\n CardProps,\n headingForCardSize,\n} from '..';\nimport { Icon, arrowRight, featherLogo } from '../icons';\n\nimport styles from './style.module.scss';\n\nconst containerStyleFromTitleSize = (\n titleSize: 'xsmall' | 'small' | 'medium' | 'big'\n): string => {\n switch (titleSize) {\n case 'xsmall':\n return 'container--xsmall';\n default:\n return 'container';\n }\n};\n\nexport type CardWithTopLeftIconProps = CardProps & {\n cardSize?: 'xsmall' | 'small' | 'medium' | 'big';\n leftIcon?: 'logo' | Icon;\n rightIcon?: 'arrow' | Icon;\n};\n\nexport const CardWithTopLeftIcon = ({\n className,\n title,\n cardSize = 'medium',\n children,\n leftIcon,\n rightIcon,\n state = 'actionable',\n dropshadow = true,\n ...props\n}: CardWithTopLeftIconProps) => {\n const cardStyle = `${className} ${associatedClassForCardState(\n state,\n dropshadow\n )} ${styles[containerStyleFromTitleSize(cardSize)]}`;\n\n const titleContainerStyle = styles['title-container'];\n const headingStyle = headingForCardSize(cardSize);\n const iconStyle = styles['right-icon'];\n const cardTextStyle = `p-p tc-grey-600 ${cardSize === 'xsmall' ? styles.indent : 'mt16'}`;\n\n return (\n <div className={cardStyle} {...props}>\n <div className={titleContainerStyle}>\n {leftIcon && (\n <img\n className=\"mr8\"\n width=\"28px\"\n height=\"28px\"\n src={leftIcon === 'logo' ? featherLogo.src : leftIcon.src}\n alt={leftIcon === 'logo' ? featherLogo.alt : leftIcon.src}\n />\n )}\n <div className={headingStyle}>{title}</div>\n {rightIcon && (\n <img\n className={iconStyle}\n width=\"24px\"\n height=\"24px\"\n src={rightIcon === 'arrow' ? arrowRight.src : rightIcon.src}\n alt={rightIcon === 'arrow' ? arrowRight.alt : rightIcon.alt}\n />\n )}\n </div>\n <p className={cardTextStyle}>{children}</p>\n </div>\n );\n};\n","import { associatedClassForCardState, CardProps, headingForCardSize } from '..';\nimport { Icon, arrowRight, IconSize } from '../icons';\n\nimport styles from './style.module.scss';\n\nexport type CardWithTopIconProps = CardProps & {\n topIcon: Icon;\n topIconSize: IconSize;\n cardSize?: 'small' | 'medium' | 'big';\n rightIcon?: 'arrow' | Icon;\n};\n\nexport const CardWithTopIcon = ({\n className,\n title,\n cardSize = 'medium',\n children,\n topIcon,\n topIconSize = { width: 48, height: 48 },\n rightIcon,\n state = 'actionable',\n dropshadow = true,\n ...props\n}: CardWithTopIconProps) => {\n const cardStyle = `d-flex fd-column ai-center ${className} ${associatedClassForCardState(\n state,\n dropshadow\n )} ${styles.container}`;\n\n const headingStyle = headingForCardSize(cardSize);\n const iconStyle = styles['right-icon'];\n\n return (\n <>\n <div className={cardStyle} {...props}>\n <img\n width={topIconSize.width}\n height={topIconSize.height}\n alt={topIcon.alt}\n src={topIcon.src}\n />\n <div className=\"d-flex mt16\">\n <div className={headingStyle}>{title}</div>\n {rightIcon && (\n <img\n className={iconStyle}\n width=\"24px\"\n height=\"24px\"\n src={rightIcon === 'arrow' ? arrowRight.src : rightIcon.src}\n alt={rightIcon === 'arrow' ? arrowRight.alt : rightIcon.alt}\n />\n )}\n </div>\n {children}\n </div>\n </>\n );\n};\n","import { associatedClassForCardState, CardProps } from '..';\nimport { Icon, info } from '../icons';\n\nimport styles from './style.module.scss';\n\nexport type InfoCardProps = CardProps & {\n topIcon: Icon;\n rightIcon?: 'info' | Icon;\n};\n\nexport const InfoCard = ({\n className,\n title,\n children,\n topIcon,\n rightIcon,\n state = 'actionable',\n dropshadow = true,\n ...props\n}: InfoCardProps) => (\n <div className={`${styles['root-container']} ${className ?? ''}`} {...props}>\n <img\n src={topIcon.src}\n alt={topIcon.alt}\n className={`${styles['top-icon']} ${\n state === 'muted' ? styles['top-icon--muted'] : ''\n } `}\n width=\"80px\"\n height=\"80px\"\n />\n <div\n className={`${associatedClassForCardState(state, dropshadow)} ${\n styles.container\n }`}\n >\n {rightIcon && (\n <img\n width=\"20px\"\n height=\"20px\"\n className={styles['right-icon']}\n src={rightIcon === 'info' ? info.src : rightIcon.src}\n alt={rightIcon === 'info' ? info.alt : rightIcon.alt}\n />\n )}\n <div className=\"p-h4 ta-center mt64\">{title}</div>\n <p className=\"p-p mt16 tc-grey-600\">{children}</p>\n </div>\n </div>\n);\n","import { CardWithTopLeftIcon } from './cardWithTopLeftIcon';\nimport { CardWithLeftIcon } from './cardWithLeftIcon';\nimport { CardWithTopIcon } from './cardWithTopIcon';\nimport { InfoCard } from './infoCard';\nimport { CardButton } from './cardButton';\n\ntype CardState = 'actionable' | 'static' | 'muted';\n\nexport type CardProps = {\n title: string;\n children: React.ReactNode;\n state?: CardState;\n dropshadow?: boolean;\n} & JSX.IntrinsicElements['div'];\n\nexport const headingForCardSize = (\n cardSize: 'xsmall' | 'small' | 'medium' | 'big'\n): string => {\n switch (cardSize) {\n case 'xsmall':\n case 'small':\n return 'p-h4';\n case 'medium':\n return 'p-h3';\n case 'big':\n return 'p-h2';\n }\n};\n\nexport const associatedClassForCardState = (\n state: CardState,\n dropshadow: boolean\n): string => {\n const baseClass = (() => {\n switch (state) {\n case 'actionable':\n return 'ds-card--actionable';\n case 'muted':\n return 'ds-card--muted';\n case 'static':\n return 'ds-card';\n }\n })();\n\n if (dropshadow === false) {\n return `${baseClass} ds-card--no-dropshadow`;\n }\n return baseClass;\n};\n\nexport {\n CardWithTopLeftIcon,\n CardWithLeftIcon,\n CardWithTopIcon,\n InfoCard,\n CardButton,\n};\n","import { associatedClassForCardState, CardProps, headingForCardSize } from '..';\nimport { Icon, IconSize, arrowRight } from '../icons';\n\nimport styles from './style.module.scss';\n\nconst containerStyleFromCardSize = (\n cardSize: 'xsmall' | 'small' | 'medium' | 'big'\n): string => {\n switch (cardSize) {\n case 'xsmall':\n return 'container--xsmall';\n case 'small':\n return 'container--small';\n default:\n return 'container';\n }\n};\n\nconst cardTextStyleFromCardSize = (\n cardSize: 'xsmall' | 'small' | 'medium' | 'big'\n): string => {\n switch (cardSize) {\n case 'xsmall':\n case 'small':\n return 'card-text--small';\n case 'medium':\n return 'card-text--medium';\n default:\n return 'card-text--big';\n }\n};\n\nexport type CardWithLeftIconProps = Omit<CardProps, 'title'> & {\n cardSize?: 'xsmall' | 'small' | 'medium' | 'big';\n leftIcon?: Icon;\n rightIcon?: 'arrow' | Icon;\n leftIconSize?: IconSize;\n title?: string;\n subtitle?: string;\n}\n\nexport const CardWithLeftIcon = ({\n className = '',\n title,\n subtitle,\n cardSize = 'medium',\n children,\n leftIcon,\n rightIcon,\n state = 'actionable',\n dropshadow = true,\n leftIconSize,\n ...props\n}: CardWithLeftIconProps) => {\n const cardStyle = `d-flex ai-center ${className} ${associatedClassForCardState(\n state,\n dropshadow\n )} ${styles[containerStyleFromCardSize(cardSize)]}`;\n\n const headingStyle = headingForCardSize(cardSize);\n const iconStyle = cardSize === 'xsmall' ? 'mr16' : 'mr32';\n const cardTextStyle = `tc-grey-600 ${\n cardSize === 'xsmall' ? 'p-p--small' : 'p-p '\n } ${styles[cardTextStyleFromCardSize(cardSize)]}`;\n\n return (\n <div className={cardStyle} {...props}>\n {leftIcon && (\n <img\n width={`${leftIconSize?.width || 48}px`}\n height={`${leftIconSize?.height || 48}px`}\n className={iconStyle}\n src={leftIcon.src}\n alt={leftIcon.alt}\n />\n )}\n <div>\n <div className=\"d-flex\">\n {(title || subtitle) && (\n <div>\n {title && (\n <div className={headingStyle}>{title}</div>\n )}\n {subtitle && (\n <div className={`tc-grey-500 ${headingStyle}`}>{subtitle}</div>\n )}\n </div>\n )}\n {rightIcon && (\n <img\n className=\"ml-auto\"\n width=\"24px\"\n height=\"24px\"\n src={rightIcon === 'arrow' ? arrowRight.src : rightIcon.src}\n alt={rightIcon === 'arrow' ? arrowRight.alt : rightIcon.alt}\n />\n )}\n </div>\n <p className={cardTextStyle}>{children}</p>\n </div>\n </div>\n );\n};\n"],"names":["styles","_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AASA,IAAM,2BAA2B,GAAG,UAClC,SAAgD;IAEhD,QAAQ,SAAS;QACf,KAAK,QAAQ;YACX,OAAO,mBAAmB,CAAC;QAC7B;YACE,OAAO,WAAW,CAAC;KACtB;AACH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AAS,EAAE,iBAAe,YAAc,gBAAG,QAAQ,YAAO,CAChE,YACG,CACP;4BACA,SAAS,KACRA,aACE,SAAS,EAAC,SAAS,EACnB,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,MAAM,EACb,GAAG,EAAE,SAAS,KAAK,OAAO,GAAG,UAAU,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,EAC3D,GAAG,EAAE,SAAS,KAAK,OAAO,GAAG,UAAU,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,WAC3D,CACH,aACG;oBACNA,oBAAG,SAAS,EAAE,aAAa,gBAAG,QAAQ,YAAK,YACvC,aACF,EACN;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/lib/components/cards/cardWithTopLeftIcon/index.tsx","../../../../../src/lib/components/cards/cardWithTopIcon/index.tsx","../../../../../src/lib/components/cards/infoCard/index.tsx","../../../../../src/lib/components/cards/index.tsx","../../../../../src/lib/components/cards/cardWithLeftIcon/index.tsx"],"sourcesContent":["import { associatedClassForCardState, CardProps, headingForCardSize } from '..';\nimport { arrowRight, featherLogo, Icon } from '../icons';\n\nimport styles from './style.module.scss';\n\nconst containerStyleFromTitleSize = (\n titleSize: 'xsmall' | 'small' | 'medium' | 'big'\n): string => {\n switch (titleSize) {\n case 'xsmall':\n return 'container--xsmall';\n default:\n return 'container';\n }\n};\n\nexport type CardWithTopLeftIconProps = CardProps & {\n cardSize?: 'xsmall' | 'small' | 'medium' | 'big';\n leftIcon?: 'logo' | Icon;\n rightIcon?: 'arrow' | Icon;\n};\n\nexport const CardWithTopLeftIcon = ({\n className,\n title,\n cardSize = 'medium',\n children,\n leftIcon,\n rightIcon,\n state = 'actionable',\n dropshadow = true,\n ...props\n}: CardWithTopLeftIconProps) => {\n const cardStyle = `${className} ${associatedClassForCardState(\n state,\n dropshadow\n )} ${styles[containerStyleFromTitleSize(cardSize)]}`;\n\n const titleContainerStyle = styles['title-container'];\n const headingStyle = headingForCardSize(cardSize);\n const iconStyle = styles['right-icon'];\n const cardTextStyle = `p-p tc-grey-600 ${\n cardSize === 'xsmall' ? styles.indent : 'mt16'\n }`;\n\n return (\n <div className={cardStyle} {...props}>\n <div className={titleContainerStyle}>\n {leftIcon && (\n <img\n className=\"mr8\"\n width=\"28px\"\n height=\"28px\"\n src={leftIcon === 'logo' ? featherLogo.src : leftIcon.src}\n alt={leftIcon === 'logo' ? featherLogo.alt : leftIcon.src}\n />\n )}\n <div className={headingStyle}>{title}</div>\n {rightIcon && (\n <img\n className={iconStyle}\n width=\"24px\"\n height=\"24px\"\n src={rightIcon === 'arrow' ? arrowRight.src : rightIcon.src}\n alt={rightIcon === 'arrow' ? arrowRight.alt : rightIcon.alt}\n />\n )}\n </div>\n <div className={cardTextStyle}>{children}</div>\n </div>\n );\n};\n","import { associatedClassForCardState, CardProps, headingForCardSize } from '..';\nimport { Icon, arrowRight, IconSize } from '../icons';\n\nimport styles from './style.module.scss';\n\nexport type CardWithTopIconProps = CardProps & {\n topIcon: Icon;\n topIconSize: IconSize;\n cardSize?: 'small' | 'medium' | 'big';\n rightIcon?: 'arrow' | Icon;\n};\n\nexport const CardWithTopIcon = ({\n className,\n title,\n cardSize = 'medium',\n children,\n topIcon,\n topIconSize = { width: 48, height: 48 },\n rightIcon,\n state = 'actionable',\n dropshadow = true,\n ...props\n}: CardWithTopIconProps) => {\n const cardStyle = `d-flex fd-column ai-center ${className} ${associatedClassForCardState(\n state,\n dropshadow\n )} ${styles.container}`;\n\n const headingStyle = headingForCardSize(cardSize);\n const iconStyle = styles['right-icon'];\n\n return (\n <>\n <div className={cardStyle} {...props}>\n <img\n width={topIconSize.width}\n height={topIconSize.height}\n alt={topIcon.alt}\n src={topIcon.src}\n />\n <div className=\"d-flex mt16\">\n <div className={headingStyle}>{title}</div>\n {rightIcon && (\n <img\n className={iconStyle}\n width=\"24px\"\n height=\"24px\"\n src={rightIcon === 'arrow' ? arrowRight.src : rightIcon.src}\n alt={rightIcon === 'arrow' ? arrowRight.alt : rightIcon.alt}\n />\n )}\n </div>\n {children}\n </div>\n </>\n );\n};\n","import { associatedClassForCardState, CardProps } from '..';\nimport { Icon, info } from '../icons';\n\nimport styles from './style.module.scss';\n\nexport type InfoCardProps = CardProps & {\n topIcon: Icon;\n rightIcon?: 'info' | Icon;\n};\n\nexport const InfoCard = ({\n className,\n title,\n children,\n topIcon,\n rightIcon,\n state = 'actionable',\n dropshadow = true,\n ...props\n}: InfoCardProps) => (\n <div className={`${styles['root-container']} ${className ?? ''}`} {...props}>\n <img\n src={topIcon.src}\n alt={topIcon.alt}\n className={`${styles['top-icon']} ${\n state === 'muted' ? styles['top-icon--muted'] : ''\n } `}\n width=\"80px\"\n height=\"80px\"\n />\n <div\n className={`${associatedClassForCardState(state, dropshadow)} ${\n styles.container\n }`}\n >\n {rightIcon && (\n <img\n width=\"20px\"\n height=\"20px\"\n className={styles['right-icon']}\n src={rightIcon === 'info' ? info.src : rightIcon.src}\n alt={rightIcon === 'info' ? info.alt : rightIcon.alt}\n />\n )}\n <div className=\"p-h4 ta-center mt64\">{title}</div>\n <p className=\"p-p mt16 tc-grey-600\">{children}</p>\n </div>\n </div>\n);\n","import { CardWithTopLeftIcon } from './cardWithTopLeftIcon';\nimport { CardWithLeftIcon } from './cardWithLeftIcon';\nimport { CardWithTopIcon } from './cardWithTopIcon';\nimport { InfoCard } from './infoCard';\nimport { CardButton } from './cardButton';\n\ntype CardState = 'actionable' | 'static' | 'muted';\n\nexport type CardProps = {\n title: string;\n children: React.ReactNode;\n state?: CardState;\n dropshadow?: boolean;\n} & JSX.IntrinsicElements['div'];\n\nexport const headingForCardSize = (\n cardSize: 'xsmall' | 'small' | 'medium' | 'big'\n): string => {\n switch (cardSize) {\n case 'xsmall':\n case 'small':\n return 'p-h4';\n case 'medium':\n return 'p-h3';\n case 'big':\n return 'p-h2';\n }\n};\n\nexport const associatedClassForCardState = (\n state: CardState,\n dropshadow: boolean\n): string => {\n const baseClass = (() => {\n switch (state) {\n case 'actionable':\n return 'ds-card--actionable';\n case 'muted':\n return 'ds-card--muted';\n case 'static':\n return 'ds-card';\n }\n })();\n\n if (dropshadow === false) {\n return `${baseClass} ds-card--no-dropshadow`;\n }\n return baseClass;\n};\n\nexport {\n CardWithTopLeftIcon,\n CardWithLeftIcon,\n CardWithTopIcon,\n InfoCard,\n CardButton,\n};\n","import { associatedClassForCardState, CardProps, headingForCardSize } from '..';\nimport { arrowRight, Icon, IconSize } from '../icons';\n\nimport styles from './style.module.scss';\n\nconst containerStyleFromCardSize = (\n cardSize: 'xsmall' | 'small' | 'medium' | 'big'\n): string => {\n switch (cardSize) {\n case 'xsmall':\n return 'container--xsmall';\n case 'small':\n return 'container--small';\n default:\n return 'container';\n }\n};\n\nconst cardTextStyleFromCardSize = (\n cardSize: 'xsmall' | 'small' | 'medium' | 'big'\n): string => {\n switch (cardSize) {\n case 'xsmall':\n case 'small':\n return 'card-text--small';\n case 'medium':\n return 'card-text--medium';\n default:\n return 'card-text--big';\n }\n};\n\nexport type CardWithLeftIconProps = Omit<CardProps, 'title'> & {\n cardSize?: 'xsmall' | 'small' | 'medium' | 'big';\n leftIcon?: Icon;\n rightIcon?: 'arrow' | Icon;\n leftIconSize?: IconSize;\n title?: string;\n subtitle?: string;\n};\n\nexport const CardWithLeftIcon = ({\n className = '',\n title,\n subtitle,\n cardSize = 'medium',\n children,\n leftIcon,\n rightIcon,\n state = 'actionable',\n dropshadow = true,\n leftIconSize,\n ...props\n}: CardWithLeftIconProps) => {\n const cardStyle = `d-flex ai-center ${className} ${associatedClassForCardState(\n state,\n dropshadow\n )} ${styles[containerStyleFromCardSize(cardSize)]}`;\n\n const headingStyle = headingForCardSize(cardSize);\n const iconStyle = cardSize === 'xsmall' ? 'mr16' : 'mr32';\n const cardTextStyle = `tc-grey-600 ${\n cardSize === 'xsmall' ? 'p-p--small' : 'p-p '\n } ${styles[cardTextStyleFromCardSize(cardSize)]}`;\n\n return (\n <div className={cardStyle} {...props}>\n {leftIcon && (\n <img\n width={`${leftIconSize?.width || 48}px`}\n height={`${leftIconSize?.height || 48}px`}\n className={iconStyle}\n src={leftIcon.src}\n alt={leftIcon.alt}\n />\n )}\n <div>\n <div className=\"d-flex\">\n {(title || subtitle) && (\n <div>\n {title && <div className={headingStyle}>{title}</div>}\n {subtitle && (\n <div className={`tc-grey-500 ${headingStyle}`}>{subtitle}</div>\n )}\n </div>\n )}\n {rightIcon && (\n <img\n className=\"ml-auto\"\n width=\"24px\"\n height=\"24px\"\n src={rightIcon === 'arrow' ? arrowRight.src : rightIcon.src}\n alt={rightIcon === 'arrow' ? arrowRight.alt : rightIcon.alt}\n />\n )}\n </div>\n <div className={cardTextStyle}>{children}</div>\n </div>\n </div>\n );\n};\n"],"names":["styles","_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAKA,IAAM,2BAA2B,GAAG,UAClC,SAAgD;IAEhD,QAAQ,SAAS;QACf,KAAK,QAAQ;YACX,OAAO,mBAAmB,CAAC;QAC7B;YACE,OAAO,WAAW,CAAC;KACtB;AACH,CAAC,CAAC;IAQW,mBAAmB,GAAG,UAAC,EAUT;IATzB,IAAA,SAAS,eAAA,EACT,KAAK,WAAA,EACL,gBAAmB,EAAnB,QAAQ,mBAAG,QAAQ,KAAA,EACnB,QAAQ,cAAA,EACR,QAAQ,cAAA,EACR,SAAS,eAAA,EACT,aAAoB,EAApB,KAAK,mBAAG,YAAY,KAAA,EACpB,kBAAiB,EAAjB,UAAU,mBAAG,IAAI,KAAA,EACd,KAAK,cAT0B,8FAUnC,CADS;IAER,IAAM,SAAS,GAAM,SAAS,SAAI,2BAA2B,CAC3D,KAAK,EACL,UAAU,CACX,SAAIA,QAAM,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAG,CAAC;IAErD,IAAM,mBAAmB,GAAGA,QAAM,CAAC,iBAAiB,CAAC,CAAC;IACtD,IAAM,YAAY,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAClD,IAAM,SAAS,GAAGA,QAAM,CAA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,KAAK,QAAQ,GAAG,YAAY,GAAG,MAAM,UAC3C,MAAM,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAG,CAAC;IAElD,QACED,uBAAK,SAAS,EAAE,SAAS,IAAM,KAAK,eACjC,QAAQ,KACPC,aACE,KAAK,EAAE,CAAG,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,KAAI,EAAE,QAAI,EACvC,MAAM,EAAE,CAAG,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,KAAI,EAAE,QAAI,EACzC,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,QAAQ,CAAC,GAAG,EACjB,GAAG,EAAE,QAAQ,CAAC,GAAG,WACjB,CACH;YACDD,yBACEA,uBAAK,SAAS,EAAC,QAAQ,iBACpB,CAAC,KAAK,IAAI,QAAQ,MACjBA,yBACG,KAAK,IAAIC,sBAAK,SAAS,EAAE,YAAY,gBAAG,KAAK,YAAO;oCACpD,QAAQ,KACPA,sBAAK,SAAS,EAAE,iBAAe,YAAc,gBAAG,QAAQ,YAAO,CAChE,YACG,CACP;4BACA,SAAS,KACRA,aACE,SAAS,EAAC,SAAS,EACnB,KAAK,EAAC,MAAM,EACZ,MAAM,EAAC,MAAM,EACb,GAAG,EAAE,SAAS,KAAK,OAAO,GAAG,UAAU,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,EAC3D,GAAG,EAAE,SAAS,KAAK,OAAO,GAAG,UAAU,CAAC,GAAG,GAAG,SAAS,CAAC,GAAG,WAC3D,CACH,aACG;oBACNA,sBAAK,SAAS,EAAE,aAAa,gBAAG,QAAQ,YAAO,YAC3C,aACF,EACN;AACJ;;;;"}
|
|
@@ -3,6 +3,23 @@ export interface AutocompleteAddressProps {
|
|
|
3
3
|
apiKey: string;
|
|
4
4
|
address?: Partial<Address>;
|
|
5
5
|
onAddressChange: (address: Partial<Address>) => void;
|
|
6
|
+
inputProps?: {
|
|
7
|
+
street?: {
|
|
8
|
+
name?: string;
|
|
9
|
+
};
|
|
10
|
+
houseNumber?: {
|
|
11
|
+
name?: string;
|
|
12
|
+
};
|
|
13
|
+
additionalInformation?: {
|
|
14
|
+
name?: string;
|
|
15
|
+
};
|
|
16
|
+
postcode?: {
|
|
17
|
+
name?: string;
|
|
18
|
+
};
|
|
19
|
+
city?: {
|
|
20
|
+
name?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
6
23
|
placeholders?: {
|
|
7
24
|
manualAddressEntry?: string;
|
|
8
25
|
street?: string;
|
|
@@ -16,5 +33,5 @@ export interface AutocompleteAddressProps {
|
|
|
16
33
|
cta?: string;
|
|
17
34
|
};
|
|
18
35
|
}
|
|
19
|
-
declare const AutocompleteAddress: ({ apiKey, address: initialAddress, onAddressChange, placeholders, manualAddressEntryTexts, }: AutocompleteAddressProps) => JSX.Element;
|
|
36
|
+
declare const AutocompleteAddress: ({ apiKey, address: initialAddress, onAddressChange, placeholders, manualAddressEntryTexts, inputProps, }: AutocompleteAddressProps) => JSX.Element;
|
|
20
37
|
export { AutocompleteAddress };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AutocompleteAddressProps } from '.';
|
|
2
2
|
declare const story: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ apiKey, address: initialAddress, onAddressChange, placeholders, manualAddressEntryTexts, }: AutocompleteAddressProps) => JSX.Element;
|
|
4
|
+
component: ({ apiKey, address: initialAddress, onAddressChange, placeholders, manualAddressEntryTexts, inputProps, }: AutocompleteAddressProps) => JSX.Element;
|
|
5
5
|
argTypes: {
|
|
6
6
|
address: {
|
|
7
7
|
description: string;
|
package/package.json
CHANGED
|
@@ -9,49 +9,55 @@ const story = {
|
|
|
9
9
|
address: {
|
|
10
10
|
description: 'The address properties',
|
|
11
11
|
table: {
|
|
12
|
-
type: {
|
|
13
|
-
summary: 'Partial<Address>'
|
|
12
|
+
type: {
|
|
13
|
+
summary: 'Partial<Address>',
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
apiKey: {
|
|
18
18
|
defaultValue: 'AIzaSyDg0DSrjYKt5smmsjkVasDz7c4T5rbOXT8',
|
|
19
|
-
description:
|
|
19
|
+
description:
|
|
20
|
+
'Your private API key for the [Google Places API](https://developers.google.com/maps/documentation/places/web-service/overview)',
|
|
20
21
|
table: {
|
|
21
|
-
type: {
|
|
22
|
-
summary: 'Partial<Address>'
|
|
22
|
+
type: {
|
|
23
|
+
summary: 'Partial<Address>',
|
|
23
24
|
},
|
|
24
25
|
},
|
|
25
26
|
},
|
|
26
27
|
onAddressChange: {
|
|
27
|
-
description:
|
|
28
|
+
description:
|
|
29
|
+
'Callback with the updated address, this function will get called everytime the address gets updated',
|
|
28
30
|
action: true,
|
|
29
31
|
table: {
|
|
30
|
-
category:
|
|
32
|
+
category: 'Callbacks',
|
|
31
33
|
},
|
|
32
34
|
},
|
|
33
35
|
manualAddressEntryTexts: {
|
|
34
|
-
description:
|
|
36
|
+
description:
|
|
37
|
+
'The CTA that enables manual address entry and the text preceding it',
|
|
35
38
|
table: {
|
|
36
39
|
type: {
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
+
summary: '{ preText?: string; cta: string?; }',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
40
43
|
},
|
|
41
44
|
placeholders: {
|
|
42
45
|
description: 'Placeholder text',
|
|
43
46
|
table: {
|
|
44
47
|
type: {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
summary:
|
|
49
|
+
'{ manualAddressEntry?: string; street: string?; houseNumber?: string; additionalInformation?: string; postcode?: string; city?: string; }',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
49
53
|
},
|
|
50
54
|
parameters: {
|
|
51
|
-
componentSubtitle:
|
|
55
|
+
componentSubtitle:
|
|
56
|
+
'Autocomplete Address are user interface elements which allow users start typing an address and get autocompletion suggestions on the address.',
|
|
52
57
|
docs: {
|
|
53
58
|
description: {
|
|
54
|
-
|
|
59
|
+
component:
|
|
60
|
+
'This component is for now only restricted to "address" types and will restrict every query to Germany.',
|
|
55
61
|
},
|
|
56
62
|
},
|
|
57
63
|
customTypes: {
|
|
@@ -62,8 +68,8 @@ const story = {
|
|
|
62
68
|
city: string;
|
|
63
69
|
additionalInformation?: string;
|
|
64
70
|
country: string;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
71
|
+
}`,
|
|
72
|
+
},
|
|
67
73
|
},
|
|
68
74
|
};
|
|
69
75
|
|
|
@@ -74,9 +80,11 @@ export const AutocompleteAddressStory = ({
|
|
|
74
80
|
onAddressChange,
|
|
75
81
|
placeholders,
|
|
76
82
|
}: AutocompleteAddressProps) => {
|
|
77
|
-
const [address, setAddress] = useState<Partial<Address> | undefined>(
|
|
83
|
+
const [address, setAddress] = useState<Partial<Address> | undefined>(
|
|
84
|
+
defaultAddress
|
|
85
|
+
);
|
|
78
86
|
const handleOnAddressChange = (newAddress: Partial<Address>) => {
|
|
79
|
-
onAddressChange(newAddress);
|
|
87
|
+
onAddressChange?.(newAddress);
|
|
80
88
|
setAddress(newAddress);
|
|
81
89
|
};
|
|
82
90
|
|
|
@@ -91,24 +99,24 @@ export const AutocompleteAddressStory = ({
|
|
|
91
99
|
);
|
|
92
100
|
};
|
|
93
101
|
|
|
94
|
-
AutocompleteAddressStory.storyName =
|
|
102
|
+
AutocompleteAddressStory.storyName = 'AutocompleteAddress';
|
|
95
103
|
|
|
96
104
|
export const WithAddress = ({
|
|
97
105
|
apiKey,
|
|
98
106
|
onAddressChange,
|
|
99
107
|
placeholders,
|
|
100
108
|
}: AutocompleteAddressProps) => (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
<AutocompleteAddress
|
|
110
|
+
address={{
|
|
111
|
+
street: 'Lohmuehlenstraße',
|
|
112
|
+
houseNumber: '65',
|
|
113
|
+
city: 'Berlin',
|
|
114
|
+
country: 'DE',
|
|
115
|
+
additionalInformation: 'c/o Factory',
|
|
116
|
+
}}
|
|
117
|
+
apiKey={apiKey}
|
|
118
|
+
onAddressChange={onAddressChange}
|
|
119
|
+
/>
|
|
112
120
|
);
|
|
113
121
|
|
|
114
122
|
export const WithLocalisationEntryText = ({
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
1
|
+
import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import debounce from 'lodash.debounce';
|
|
4
|
-
import isEqual from 'lodash.isequal';
|
|
5
4
|
import { Input } from '../input';
|
|
6
5
|
import {
|
|
7
6
|
Address,
|
|
8
|
-
countryNameFromAlphaCode,
|
|
9
7
|
Alpha2CountryCode,
|
|
8
|
+
countryNameFromAlphaCode,
|
|
10
9
|
} from '@popsure/public-models';
|
|
11
10
|
|
|
12
11
|
import { geocoderAddressComponentToPartialAddress } from './util';
|
|
@@ -53,6 +52,23 @@ export interface AutocompleteAddressProps {
|
|
|
53
52
|
apiKey: string;
|
|
54
53
|
address?: Partial<Address>;
|
|
55
54
|
onAddressChange: (address: Partial<Address>) => void;
|
|
55
|
+
inputProps?: {
|
|
56
|
+
street?: {
|
|
57
|
+
name?: string;
|
|
58
|
+
};
|
|
59
|
+
houseNumber?: {
|
|
60
|
+
name?: string;
|
|
61
|
+
};
|
|
62
|
+
additionalInformation?: {
|
|
63
|
+
name?: string;
|
|
64
|
+
};
|
|
65
|
+
postcode?: {
|
|
66
|
+
name?: string;
|
|
67
|
+
};
|
|
68
|
+
city?: {
|
|
69
|
+
name?: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
56
72
|
placeholders?: {
|
|
57
73
|
manualAddressEntry?: string;
|
|
58
74
|
street?: string;
|
|
@@ -73,6 +89,7 @@ const AutocompleteAddress = ({
|
|
|
73
89
|
onAddressChange,
|
|
74
90
|
placeholders,
|
|
75
91
|
manualAddressEntryTexts,
|
|
92
|
+
inputProps,
|
|
76
93
|
}: AutocompleteAddressProps) => {
|
|
77
94
|
const [manualAddressEntry, setManualAddressEntry] = useState(false);
|
|
78
95
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -99,15 +116,12 @@ const AutocompleteAddress = ({
|
|
|
99
116
|
autocompleteElement.current.value = address.street;
|
|
100
117
|
}
|
|
101
118
|
|
|
102
|
-
if (isEqual(address, initialAddress) === false) {
|
|
103
|
-
onAddressChange({ ...address });
|
|
104
|
-
}
|
|
105
119
|
handleEnterAddressManually();
|
|
106
120
|
}
|
|
107
|
-
}, [
|
|
121
|
+
}, [address, onAddressChange, hasLoadedGoogleAPI]);
|
|
108
122
|
|
|
109
123
|
useEffect(() => {
|
|
110
|
-
if (hasLoadedGoogleAPI
|
|
124
|
+
if (!hasLoadedGoogleAPI) {
|
|
111
125
|
return;
|
|
112
126
|
}
|
|
113
127
|
|
|
@@ -156,6 +170,7 @@ const AutocompleteAddress = ({
|
|
|
156
170
|
...geocoderAddress,
|
|
157
171
|
additionalInformation: oldValue?.additionalInformation,
|
|
158
172
|
}));
|
|
173
|
+
onAddressChange?.(geocoderAddress);
|
|
159
174
|
}
|
|
160
175
|
|
|
161
176
|
map.current?.panTo(newPlace.geometry.location);
|
|
@@ -204,12 +219,28 @@ const AutocompleteAddress = ({
|
|
|
204
219
|
[]
|
|
205
220
|
);
|
|
206
221
|
|
|
207
|
-
const debouncedSetPlace = debounce(setPlaceFromAddress,
|
|
222
|
+
const debouncedSetPlace = debounce(setPlaceFromAddress, 2000);
|
|
208
223
|
|
|
209
224
|
const handleEnterAddressManually = () => {
|
|
210
225
|
setManualAddressEntry(true);
|
|
211
226
|
};
|
|
212
227
|
|
|
228
|
+
const onManualAddressChange =
|
|
229
|
+
({ updatePlace } = { updatePlace: true }) =>
|
|
230
|
+
(e: ChangeEvent<HTMLInputElement>) => {
|
|
231
|
+
const newAddress = {
|
|
232
|
+
...address,
|
|
233
|
+
[e.target.name]: e.target.value,
|
|
234
|
+
country: GERMANY_ALPHA_CODE,
|
|
235
|
+
};
|
|
236
|
+
setAddress(newAddress);
|
|
237
|
+
onAddressChange(newAddress);
|
|
238
|
+
|
|
239
|
+
if (updatePlace) {
|
|
240
|
+
debouncedSetPlace(newAddress);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
213
244
|
return (
|
|
214
245
|
<>
|
|
215
246
|
<div
|
|
@@ -257,15 +288,9 @@ const AutocompleteAddress = ({
|
|
|
257
288
|
type="text"
|
|
258
289
|
placeholder={placeholders?.street || 'Street'}
|
|
259
290
|
value={address?.street || ''}
|
|
260
|
-
onChange={(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
street: e.target.value,
|
|
264
|
-
country: GERMANY_ALPHA_CODE,
|
|
265
|
-
};
|
|
266
|
-
setAddress(newAddress);
|
|
267
|
-
debouncedSetPlace(newAddress);
|
|
268
|
-
}}
|
|
291
|
+
onChange={onManualAddressChange()}
|
|
292
|
+
name="street"
|
|
293
|
+
{...inputProps?.street}
|
|
269
294
|
/>
|
|
270
295
|
<Input
|
|
271
296
|
className={`wmx2 ${styles['house-number-input']}`}
|
|
@@ -273,15 +298,9 @@ const AutocompleteAddress = ({
|
|
|
273
298
|
key="autocomplete-house-number"
|
|
274
299
|
placeholder={placeholders?.houseNumber || 'House Number'}
|
|
275
300
|
value={address?.houseNumber || ''}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
houseNumber: e.target.value,
|
|
280
|
-
country: GERMANY_ALPHA_CODE,
|
|
281
|
-
};
|
|
282
|
-
setAddress(newAddress);
|
|
283
|
-
debouncedSetPlace(newAddress);
|
|
284
|
-
}}
|
|
301
|
+
name="houseNumber"
|
|
302
|
+
onChange={onManualAddressChange()}
|
|
303
|
+
{...inputProps?.houseNumber}
|
|
285
304
|
/>
|
|
286
305
|
</div>
|
|
287
306
|
<Input
|
|
@@ -293,14 +312,9 @@ const AutocompleteAddress = ({
|
|
|
293
312
|
'Additional information (C/O, apartment, …)'
|
|
294
313
|
}
|
|
295
314
|
value={address?.additionalInformation || ''}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
additionalInformation: e.target.value,
|
|
300
|
-
country: GERMANY_ALPHA_CODE,
|
|
301
|
-
};
|
|
302
|
-
setAddress(newAddress);
|
|
303
|
-
}}
|
|
315
|
+
name="additionalInformation"
|
|
316
|
+
onChange={onManualAddressChange({ updatePlace: false })}
|
|
317
|
+
{...inputProps?.additionalInformation}
|
|
304
318
|
/>
|
|
305
319
|
<div className={`d-flex mt16 c-gap16 ${styles['input-line']}`}>
|
|
306
320
|
<Input
|
|
@@ -309,15 +323,9 @@ const AutocompleteAddress = ({
|
|
|
309
323
|
key="autocomplete-postcode"
|
|
310
324
|
placeholder={placeholders?.postcode || 'Postcode'}
|
|
311
325
|
value={address?.postcode || ''}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
postcode: e.target.value,
|
|
316
|
-
country: GERMANY_ALPHA_CODE,
|
|
317
|
-
};
|
|
318
|
-
setAddress(newAddress);
|
|
319
|
-
debouncedSetPlace(newAddress);
|
|
320
|
-
}}
|
|
326
|
+
name="postcode"
|
|
327
|
+
onChange={onManualAddressChange()}
|
|
328
|
+
{...inputProps?.postcode}
|
|
321
329
|
/>
|
|
322
330
|
<Input
|
|
323
331
|
className="w100"
|
|
@@ -325,15 +333,9 @@ const AutocompleteAddress = ({
|
|
|
325
333
|
key="autocomplete-city"
|
|
326
334
|
placeholder={placeholders?.city || 'City'}
|
|
327
335
|
value={address?.city || ''}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
city: e.target.value,
|
|
332
|
-
country: GERMANY_ALPHA_CODE,
|
|
333
|
-
};
|
|
334
|
-
setAddress(newAddress);
|
|
335
|
-
debouncedSetPlace(newAddress);
|
|
336
|
-
}}
|
|
336
|
+
name="city"
|
|
337
|
+
onChange={onManualAddressChange()}
|
|
338
|
+
{...inputProps?.city}
|
|
337
339
|
/>
|
|
338
340
|
</div>
|
|
339
341
|
</>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { associatedClassForCardState, CardProps, headingForCardSize } from '..';
|
|
2
|
-
import { Icon, IconSize
|
|
2
|
+
import { arrowRight, Icon, IconSize } from '../icons';
|
|
3
3
|
|
|
4
4
|
import styles from './style.module.scss';
|
|
5
5
|
|
|
@@ -37,7 +37,7 @@ export type CardWithLeftIconProps = Omit<CardProps, 'title'> & {
|
|
|
37
37
|
leftIconSize?: IconSize;
|
|
38
38
|
title?: string;
|
|
39
39
|
subtitle?: string;
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
|
|
42
42
|
export const CardWithLeftIcon = ({
|
|
43
43
|
className = '',
|
|
@@ -78,9 +78,7 @@ export const CardWithLeftIcon = ({
|
|
|
78
78
|
<div className="d-flex">
|
|
79
79
|
{(title || subtitle) && (
|
|
80
80
|
<div>
|
|
81
|
-
{title &&
|
|
82
|
-
<div className={headingStyle}>{title}</div>
|
|
83
|
-
)}
|
|
81
|
+
{title && <div className={headingStyle}>{title}</div>}
|
|
84
82
|
{subtitle && (
|
|
85
83
|
<div className={`tc-grey-500 ${headingStyle}`}>{subtitle}</div>
|
|
86
84
|
)}
|
|
@@ -96,7 +94,7 @@ export const CardWithLeftIcon = ({
|
|
|
96
94
|
/>
|
|
97
95
|
)}
|
|
98
96
|
</div>
|
|
99
|
-
<
|
|
97
|
+
<div className={cardTextStyle}>{children}</div>
|
|
100
98
|
</div>
|
|
101
99
|
</div>
|
|
102
100
|
);
|