@brikka/locations 1.0.6 → 1.0.7

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/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./lib/AddLocationButton";
2
+ export * from "./lib/SidebarMapsCard";
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ButtonBarButtonProps } from "@compill/admin";
3
2
  import { API } from "@compill/api";
4
3
  import { Location } from "@compill/models";
@@ -0,0 +1,33 @@
1
+ import { ButtonBarButton, ItemEditDialog } from "@compill/admin";
2
+ import { FormHelper } from "@compill/form";
3
+ import { mapsHelper } from "@compill/form-maps";
4
+ import { useModal } from "@compill/hooks";
5
+ import { mdiPlus } from "@mdi/js";
6
+ import * as Yup from "yup";
7
+ const editForm = (lat, lng, mapZoom, locationTypeLabel) => FormHelper.array(mapsHelper("location", `Search a ${locationTypeLabel}`, lat, lng, mapZoom), FormHelper.condition("location", (location) => location != null && Object.keys(location).length > 0, FormHelper.array(FormHelper.divider(), FormHelper.input("map.addressName", "Name"), FormHelper.input("map.addressStreet", "Address", false, undefined, { disabled: true }))));
8
+ const editInitialValues = () => ({
9
+ type: "google",
10
+ location: {}
11
+ });
12
+ const editSchema = Yup.object().shape({
13
+ // name: Yup.string().required("Please set a name for your organisation"),
14
+ // type: Yup.string().required("Please select a type"),
15
+ });
16
+ export function NewLocationButton({ api, lat, lng, mapZoom, locationTypeLabel = "location", ...props }) {
17
+ const { isOpen, onOpen, modalProps } = useModal();
18
+ return (<>
19
+ <ButtonBarButton size="md" icon={mdiPlus} onClick={onOpen} {...props}>
20
+ New Venue
21
+ </ButtonBarButton>
22
+
23
+ {isOpen && (<ItemEditDialog api={api} form={editForm(lat, lng, mapZoom, locationTypeLabel)} initialValues={editInitialValues} formToQueryData={(values) => ({
24
+ type: "google",
25
+ ext_id: values.map.googleMapsPlaceId,
26
+ lat: values.map.lat,
27
+ lng: values.map.lng,
28
+ name: values.map.addressName,
29
+ address: values.map.addressStreet,
30
+ mapZoom
31
+ })} itemLabel={locationTypeLabel} formikProps={{ validationSchema: editSchema }} {...modalProps}/>)}
32
+ </>);
33
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Location } from "@compill/models";
3
2
  interface SidebarMapsCardProps {
4
3
  location?: Location;
@@ -0,0 +1,41 @@
1
+ import { FlexCenter } from "@compill/components";
2
+ import { useCopyToClipboard } from "@compill/hooks";
3
+ import { NextImageFill } from "@compill/next";
4
+ import { mdiContentCopy, mdiMapMarker } from "@mdi/js";
5
+ import { IconButton } from "@valerya/ui";
6
+ import { SidebarCard } from "@brikka/layout";
7
+ export function SidebarMapsCard({ title, location }) {
8
+ const copy = useCopyToClipboard(location?.address ?? location?.name ?? "", "Address copied!");
9
+ const googleMapsLink = `https://www.google.com/maps/search/?api=1&query=${location?.lat},${location?.lng}`;
10
+ if (!location)
11
+ return null;
12
+ if (!location.name && !location.address && location.media)
13
+ return null;
14
+ return (<SidebarCard icon={mdiMapMarker} title={title || "Location"}>
15
+ <div bgColor="white" p="5">
16
+ {(location.name || location.address) &&
17
+ (<>
18
+ <div ps="2" dflex alignItems="center">
19
+ <span flexGrow>{location.name ? location.name : location.address}</span>
20
+ <span>
21
+ <IconButton variant="borderless" scheme="secondary" size="lg" rounded="full" icon={mdiContentCopy} onClick={copy}/>
22
+ </span>
23
+ </div>
24
+
25
+ {/* TODO Retrieve full address in fb api */}
26
+ {location.name && location.address && <div ps="2" textColor="slate-600" textSize="sm">{location.address}</div>}
27
+ </>)}
28
+
29
+ {location.media &&
30
+ (<div aspectRatio="16/10" group position="relative">
31
+ <NextImageFill showLoadingStates src={location.media?.url ?? ""} alt="Google Maps" size='33vw' sm_size='33vw' md_size='33vw' lg_size='448px' xl_size='448px' x2_size='448px' width={location.media?.width ?? 0} height={location.media?.height ?? 0}/>
32
+
33
+ <a href={googleMapsLink} target="_blank" rel="nofollow">
34
+ <FlexCenter opacity="0" groupHover_opacity="100" position="absolute" top="0" start="0" w="full" h="full" bgColor="black" bgOpacity="50" textColor="white" fontWeight="500" textSize="lg" transition="all" easing="in-out" duration="500">
35
+ Open in Google Maps
36
+ </FlexCenter>
37
+ </a>
38
+ </div>)}
39
+ </div>
40
+ </SidebarCard>);
41
+ }
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
- "name": "@brikka/locations",
3
- "version": "1.0.6",
4
- "module": "./index.esm.js",
5
- "main": "./index.cjs.js"
2
+ "name": "@brikka/locations",
3
+ "version": "1.0.7",
4
+ "private": false,
5
+ "sideEffects": false,
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ }
12
+ },
13
+ "devDependencies": {
14
+ "eslint": "^9.38.0",
15
+ "typescript": "5.9.2",
16
+ "@types/react": "^18.3.1",
17
+ "@repo/eslint-config": "0.0.0",
18
+ "@repo/typescript-config": "0.0.0"
19
+ },
20
+ "peerDependencies": {
21
+ "react": "^18.3.1",
22
+ "next": "^15.5.4"
23
+ },
24
+ "dependencies": {
25
+ "@mdi/js": "^7.4.47",
26
+ "yup": "^1.1.0",
27
+ "@soperio/react": "1.0.14",
28
+ "@soperio/jsx-runtime": "1.0.14",
29
+ "@valerya/ui": "1.0.9",
30
+ "@brikka/layout": "1.0.80",
31
+ "@compill/admin": "1.0.102",
32
+ "@compill/api": "1.0.57",
33
+ "@compill/auth": "1.0.77",
34
+ "@compill/components": "1.0.49",
35
+ "@compill/form-maps": "1.0.14",
36
+ "@compill/form": "1.0.67",
37
+ "@compill/next": "1.0.58",
38
+ "@compill/models": "1.0.12",
39
+ "@compill/hooks": "1.0.43"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "files": [
45
+ "dist"
46
+ ],
47
+ "scripts": {
48
+ "build": "tsc -p tsconfig.build.json",
49
+ "dev": "tsup src/index.ts --format esm --dts --watch",
50
+ "lint": "eslint . --max-warnings 0",
51
+ "check-types": "tsc --noEmit"
52
+ }
6
53
  }
package/index.cjs.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";