@brikka/locations 1.0.12 → 1.0.14
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.cjs +145 -0
- package/dist/index.d.ts +2 -21
- package/dist/index.js +40 -63
- package/dist/lib/AddLocationButton.d.ts +11 -0
- package/dist/lib/SidebarMapsCard.d.ts +8 -0
- package/package.json +15 -22
- package/dist/index.d.mts +0 -21
- package/dist/index.mjs +0 -123
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('@soperio/jsx-runtime');
|
|
4
|
+
var admin = require('@compill/admin');
|
|
5
|
+
var form = require('@compill/form');
|
|
6
|
+
var formMaps = require('@compill/form-maps');
|
|
7
|
+
var hooks = require('@compill/hooks');
|
|
8
|
+
var js = require('@mdi/js');
|
|
9
|
+
var Yup = require('yup');
|
|
10
|
+
var components = require('@compill/components');
|
|
11
|
+
var next = require('@compill/next');
|
|
12
|
+
var ui = require('@valerya/ui');
|
|
13
|
+
var layout = require('@brikka/layout');
|
|
14
|
+
|
|
15
|
+
function _interopNamespaceDefault(e) {
|
|
16
|
+
var n = Object.create(null);
|
|
17
|
+
if (e) {
|
|
18
|
+
Object.keys(e).forEach(function (k) {
|
|
19
|
+
if (k !== 'default') {
|
|
20
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
21
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return e[k]; }
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
n.default = e;
|
|
29
|
+
return Object.freeze(n);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var Yup__namespace = /*#__PURE__*/_interopNamespaceDefault(Yup);
|
|
33
|
+
|
|
34
|
+
const editForm = (lat, lng, mapZoom, locationTypeLabel) => form.FormHelper.array(
|
|
35
|
+
formMaps.mapsHelper("location", `Search a ${locationTypeLabel}`, lat, lng, mapZoom),
|
|
36
|
+
form.FormHelper.condition("location", (location) => location != null && Object.keys(location).length > 0, form.FormHelper.array(
|
|
37
|
+
form.FormHelper.divider(),
|
|
38
|
+
form.FormHelper.input("map.addressName", "Name"),
|
|
39
|
+
form.FormHelper.input("map.addressStreet", "Address", false, void 0, { disabled: true })
|
|
40
|
+
))
|
|
41
|
+
);
|
|
42
|
+
const editInitialValues = () => ({
|
|
43
|
+
type: "google",
|
|
44
|
+
location: {}
|
|
45
|
+
});
|
|
46
|
+
const editSchema = Yup__namespace.object().shape({
|
|
47
|
+
// name: Yup.string().required("Please set a name for your organisation"),
|
|
48
|
+
// type: Yup.string().required("Please select a type"),
|
|
49
|
+
});
|
|
50
|
+
function NewLocationButton({ api, lat, lng, mapZoom, locationTypeLabel = "location", ...props }) {
|
|
51
|
+
const { isOpen, onOpen, modalProps } = hooks.useModal();
|
|
52
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
53
|
+
/* @__PURE__ */ jsxRuntime.jsx(admin.ButtonBarButton, { size: "md", icon: js.mdiPlus, onClick: onOpen, ...props, children: "New Venue" }),
|
|
54
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsx(
|
|
55
|
+
admin.ItemEditDialog,
|
|
56
|
+
{
|
|
57
|
+
api,
|
|
58
|
+
form: editForm(lat, lng, mapZoom, locationTypeLabel),
|
|
59
|
+
initialValues: editInitialValues,
|
|
60
|
+
formToQueryData: (values) => ({
|
|
61
|
+
type: "google",
|
|
62
|
+
ext_id: values.map.googleMapsPlaceId,
|
|
63
|
+
lat: values.map.lat,
|
|
64
|
+
lng: values.map.lng,
|
|
65
|
+
name: values.map.addressName,
|
|
66
|
+
address: values.map.addressStreet,
|
|
67
|
+
mapZoom
|
|
68
|
+
}),
|
|
69
|
+
itemLabel: locationTypeLabel,
|
|
70
|
+
formikProps: { validationSchema: editSchema },
|
|
71
|
+
...modalProps
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
] });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function SidebarMapsCard({ title, location }) {
|
|
78
|
+
const copy = hooks.useCopyToClipboard(location?.address ?? location?.name ?? "", "Address copied!");
|
|
79
|
+
const googleMapsLink = `https://www.google.com/maps/search/?api=1&query=${location?.lat},${location?.lng}`;
|
|
80
|
+
if (!location)
|
|
81
|
+
return null;
|
|
82
|
+
if (!location.name && !location.address && location.media)
|
|
83
|
+
return null;
|
|
84
|
+
return /* @__PURE__ */ jsxRuntime.jsx(layout.SidebarCard, { icon: js.mdiMapMarker, title: title || "Location", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { bgColor: "white", p: "5", children: [
|
|
85
|
+
(location.name || location.address) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
86
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { ps: "2", dflex: true, alignItems: "center", children: [
|
|
87
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { flexGrow: true, children: location.name ? location.name : location.address }),
|
|
88
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
89
|
+
ui.IconButton,
|
|
90
|
+
{
|
|
91
|
+
variant: "borderless",
|
|
92
|
+
scheme: "secondary",
|
|
93
|
+
size: "lg",
|
|
94
|
+
rounded: "full",
|
|
95
|
+
icon: js.mdiContentCopy,
|
|
96
|
+
onClick: copy
|
|
97
|
+
}
|
|
98
|
+
) })
|
|
99
|
+
] }),
|
|
100
|
+
location.name && location.address && /* @__PURE__ */ jsxRuntime.jsx("div", { ps: "2", textColor: "slate-600", textSize: "sm", children: location.address })
|
|
101
|
+
] }),
|
|
102
|
+
location.media && /* @__PURE__ */ jsxRuntime.jsxs("div", { aspectRatio: "16/10", group: true, position: "relative", children: [
|
|
103
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
104
|
+
next.NextImageFill,
|
|
105
|
+
{
|
|
106
|
+
showLoadingStates: true,
|
|
107
|
+
src: location.media?.url ?? "",
|
|
108
|
+
alt: "Google Maps",
|
|
109
|
+
size: "33vw",
|
|
110
|
+
sm_size: "33vw",
|
|
111
|
+
md_size: "33vw",
|
|
112
|
+
lg_size: "448px",
|
|
113
|
+
xl_size: "448px",
|
|
114
|
+
x2_size: "448px",
|
|
115
|
+
width: location.media?.width ?? 0,
|
|
116
|
+
height: location.media?.height ?? 0
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { href: googleMapsLink, target: "_blank", rel: "nofollow", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
120
|
+
components.FlexCenter,
|
|
121
|
+
{
|
|
122
|
+
opacity: "0",
|
|
123
|
+
groupHover_opacity: "100",
|
|
124
|
+
position: "absolute",
|
|
125
|
+
top: "0",
|
|
126
|
+
start: "0",
|
|
127
|
+
w: "full",
|
|
128
|
+
h: "full",
|
|
129
|
+
bgColor: "black",
|
|
130
|
+
bgOpacity: "50",
|
|
131
|
+
textColor: "white",
|
|
132
|
+
fontWeight: "500",
|
|
133
|
+
textSize: "lg",
|
|
134
|
+
transition: "all",
|
|
135
|
+
easing: "in-out",
|
|
136
|
+
duration: "500",
|
|
137
|
+
children: "Open in Google Maps"
|
|
138
|
+
}
|
|
139
|
+
) })
|
|
140
|
+
] })
|
|
141
|
+
] }) });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
exports.NewLocationButton = NewLocationButton;
|
|
145
|
+
exports.SidebarMapsCard = SidebarMapsCard;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { Location } from '@compill/models';
|
|
4
|
-
|
|
5
|
-
interface NewLocationButtonProps extends ButtonBarButtonProps {
|
|
6
|
-
api: API<Location>;
|
|
7
|
-
lat: number;
|
|
8
|
-
lng: number;
|
|
9
|
-
mapZoom: number;
|
|
10
|
-
locationTypeLabel?: string;
|
|
11
|
-
}
|
|
12
|
-
declare function NewLocationButton({ api, lat, lng, mapZoom, locationTypeLabel, ...props }: NewLocationButtonProps): JSX.Element;
|
|
13
|
-
|
|
14
|
-
interface SidebarMapsCardProps {
|
|
15
|
-
location?: Location;
|
|
16
|
-
}
|
|
17
|
-
declare function SidebarMapsCard({ title, location }: {
|
|
18
|
-
title?: string;
|
|
19
|
-
} & SidebarMapsCardProps): JSX.Element | null;
|
|
20
|
-
|
|
21
|
-
export { NewLocationButton, type NewLocationButtonProps, SidebarMapsCard };
|
|
1
|
+
export * from "./lib/AddLocationButton";
|
|
2
|
+
export * from "./lib/SidebarMapsCard";
|
package/dist/index.js
CHANGED
|
@@ -1,60 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsxs, Fragment, jsx } from '@soperio/jsx-runtime';
|
|
2
|
+
import { ButtonBarButton, ItemEditDialog } from '@compill/admin';
|
|
3
|
+
import { FormHelper } from '@compill/form';
|
|
4
|
+
import { mapsHelper } from '@compill/form-maps';
|
|
5
|
+
import { useModal, useCopyToClipboard } from '@compill/hooks';
|
|
6
|
+
import { mdiPlus, mdiMapMarker, mdiContentCopy } from '@mdi/js';
|
|
7
|
+
import * as Yup from 'yup';
|
|
8
|
+
import { FlexCenter } from '@compill/components';
|
|
9
|
+
import { NextImageFill } from '@compill/next';
|
|
10
|
+
import { IconButton } from '@valerya/ui';
|
|
11
|
+
import { SidebarCard } from '@brikka/layout';
|
|
2
12
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var jsxRuntime = require('@soperio/jsx-runtime');
|
|
10
|
-
var components = require('@compill/components');
|
|
11
|
-
var next = require('@compill/next');
|
|
12
|
-
var ui = require('@valerya/ui');
|
|
13
|
-
var layout = require('@brikka/layout');
|
|
14
|
-
|
|
15
|
-
function _interopNamespace(e) {
|
|
16
|
-
if (e && e.__esModule) return e;
|
|
17
|
-
var n = Object.create(null);
|
|
18
|
-
if (e) {
|
|
19
|
-
Object.keys(e).forEach(function (k) {
|
|
20
|
-
if (k !== 'default') {
|
|
21
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () { return e[k]; }
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
n.default = e;
|
|
30
|
-
return Object.freeze(n);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var Yup__namespace = /*#__PURE__*/_interopNamespace(Yup);
|
|
34
|
-
|
|
35
|
-
// src/lib/AddLocationButton.tsx
|
|
36
|
-
var editForm = (lat, lng, mapZoom, locationTypeLabel) => form.FormHelper.array(
|
|
37
|
-
formMaps.mapsHelper("location", `Search a ${locationTypeLabel}`, lat, lng, mapZoom),
|
|
38
|
-
form.FormHelper.condition("location", (location) => location != null && Object.keys(location).length > 0, form.FormHelper.array(
|
|
39
|
-
form.FormHelper.divider(),
|
|
40
|
-
form.FormHelper.input("map.addressName", "Name"),
|
|
41
|
-
form.FormHelper.input("map.addressStreet", "Address", false, void 0, { disabled: true })
|
|
13
|
+
const editForm = (lat, lng, mapZoom, locationTypeLabel) => FormHelper.array(
|
|
14
|
+
mapsHelper("location", `Search a ${locationTypeLabel}`, lat, lng, mapZoom),
|
|
15
|
+
FormHelper.condition("location", (location) => location != null && Object.keys(location).length > 0, FormHelper.array(
|
|
16
|
+
FormHelper.divider(),
|
|
17
|
+
FormHelper.input("map.addressName", "Name"),
|
|
18
|
+
FormHelper.input("map.addressStreet", "Address", false, void 0, { disabled: true })
|
|
42
19
|
))
|
|
43
20
|
);
|
|
44
|
-
|
|
21
|
+
const editInitialValues = () => ({
|
|
45
22
|
type: "google",
|
|
46
23
|
location: {}
|
|
47
24
|
});
|
|
48
|
-
|
|
25
|
+
const editSchema = Yup.object().shape({
|
|
49
26
|
// name: Yup.string().required("Please set a name for your organisation"),
|
|
50
27
|
// type: Yup.string().required("Please select a type"),
|
|
51
28
|
});
|
|
52
29
|
function NewLocationButton({ api, lat, lng, mapZoom, locationTypeLabel = "location", ...props }) {
|
|
53
|
-
const { isOpen, onOpen, modalProps } =
|
|
54
|
-
return /* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
isOpen && /* @__PURE__ */
|
|
57
|
-
|
|
30
|
+
const { isOpen, onOpen, modalProps } = useModal();
|
|
31
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
32
|
+
/* @__PURE__ */ jsx(ButtonBarButton, { size: "md", icon: mdiPlus, onClick: onOpen, ...props, children: "New Venue" }),
|
|
33
|
+
isOpen && /* @__PURE__ */ jsx(
|
|
34
|
+
ItemEditDialog,
|
|
58
35
|
{
|
|
59
36
|
api,
|
|
60
37
|
form: editForm(lat, lng, mapZoom, locationTypeLabel),
|
|
@@ -75,34 +52,35 @@ function NewLocationButton({ api, lat, lng, mapZoom, locationTypeLabel = "locati
|
|
|
75
52
|
)
|
|
76
53
|
] });
|
|
77
54
|
}
|
|
55
|
+
|
|
78
56
|
function SidebarMapsCard({ title, location }) {
|
|
79
|
-
const copy =
|
|
57
|
+
const copy = useCopyToClipboard(location?.address ?? location?.name ?? "", "Address copied!");
|
|
80
58
|
const googleMapsLink = `https://www.google.com/maps/search/?api=1&query=${location?.lat},${location?.lng}`;
|
|
81
59
|
if (!location)
|
|
82
60
|
return null;
|
|
83
61
|
if (!location.name && !location.address && location.media)
|
|
84
62
|
return null;
|
|
85
|
-
return /* @__PURE__ */
|
|
86
|
-
(location.name || location.address) && /* @__PURE__ */
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
|
|
63
|
+
return /* @__PURE__ */ jsx(SidebarCard, { icon: mdiMapMarker, title: title || "Location", children: /* @__PURE__ */ jsxs("div", { bgColor: "white", p: "5", children: [
|
|
64
|
+
(location.name || location.address) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
65
|
+
/* @__PURE__ */ jsxs("div", { ps: "2", dflex: true, alignItems: "center", children: [
|
|
66
|
+
/* @__PURE__ */ jsx("span", { flexGrow: true, children: location.name ? location.name : location.address }),
|
|
67
|
+
/* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
|
|
68
|
+
IconButton,
|
|
91
69
|
{
|
|
92
70
|
variant: "borderless",
|
|
93
71
|
scheme: "secondary",
|
|
94
72
|
size: "lg",
|
|
95
73
|
rounded: "full",
|
|
96
|
-
icon:
|
|
74
|
+
icon: mdiContentCopy,
|
|
97
75
|
onClick: copy
|
|
98
76
|
}
|
|
99
77
|
) })
|
|
100
78
|
] }),
|
|
101
|
-
location.name && location.address && /* @__PURE__ */
|
|
79
|
+
location.name && location.address && /* @__PURE__ */ jsx("div", { ps: "2", textColor: "slate-600", textSize: "sm", children: location.address })
|
|
102
80
|
] }),
|
|
103
|
-
location.media && /* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
-
|
|
81
|
+
location.media && /* @__PURE__ */ jsxs("div", { aspectRatio: "16/10", group: true, position: "relative", children: [
|
|
82
|
+
/* @__PURE__ */ jsx(
|
|
83
|
+
NextImageFill,
|
|
106
84
|
{
|
|
107
85
|
showLoadingStates: true,
|
|
108
86
|
src: location.media?.url ?? "",
|
|
@@ -117,8 +95,8 @@ function SidebarMapsCard({ title, location }) {
|
|
|
117
95
|
height: location.media?.height ?? 0
|
|
118
96
|
}
|
|
119
97
|
),
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
|
|
98
|
+
/* @__PURE__ */ jsx("a", { href: googleMapsLink, target: "_blank", rel: "nofollow", children: /* @__PURE__ */ jsx(
|
|
99
|
+
FlexCenter,
|
|
122
100
|
{
|
|
123
101
|
opacity: "0",
|
|
124
102
|
groupHover_opacity: "100",
|
|
@@ -142,5 +120,4 @@ function SidebarMapsCard({ title, location }) {
|
|
|
142
120
|
] }) });
|
|
143
121
|
}
|
|
144
122
|
|
|
145
|
-
|
|
146
|
-
exports.SidebarMapsCard = SidebarMapsCard;
|
|
123
|
+
export { NewLocationButton, SidebarMapsCard };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ButtonBarButtonProps } from "@compill/admin";
|
|
2
|
+
import { API } from "@compill/api";
|
|
3
|
+
import { Location } from "@compill/models";
|
|
4
|
+
export interface NewLocationButtonProps extends ButtonBarButtonProps {
|
|
5
|
+
api: API<Location>;
|
|
6
|
+
lat: number;
|
|
7
|
+
lng: number;
|
|
8
|
+
mapZoom: number;
|
|
9
|
+
locationTypeLabel?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function NewLocationButton({ api, lat, lng, mapZoom, locationTypeLabel, ...props }: NewLocationButtonProps): JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brikka/locations",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.mjs",
|
|
13
|
-
"require": "./dist/index.js"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
9
|
"devDependencies": {
|
|
17
10
|
"eslint": "^9.38.0",
|
|
18
11
|
"typescript": "5.9.2",
|
|
@@ -27,19 +20,19 @@
|
|
|
27
20
|
"dependencies": {
|
|
28
21
|
"@mdi/js": "^7.4.47",
|
|
29
22
|
"yup": "^1.1.0",
|
|
30
|
-
"@soperio/
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@compill/
|
|
35
|
-
"@brikka/layout": "1.0.
|
|
36
|
-
"@compill/
|
|
37
|
-
"@compill/
|
|
38
|
-
"@compill/
|
|
39
|
-
"@compill/hooks": "1.0.
|
|
40
|
-
"@compill/
|
|
41
|
-
"@compill/models": "1.0.
|
|
42
|
-
"@compill/
|
|
23
|
+
"@soperio/jsx-runtime": "1.0.24",
|
|
24
|
+
"@valerya/ui": "1.0.27",
|
|
25
|
+
"@compill/admin": "1.0.113",
|
|
26
|
+
"@soperio/react": "1.0.24",
|
|
27
|
+
"@compill/form-maps": "1.0.22",
|
|
28
|
+
"@brikka/layout": "1.0.90",
|
|
29
|
+
"@compill/auth": "1.0.88",
|
|
30
|
+
"@compill/api": "1.0.65",
|
|
31
|
+
"@compill/next": "1.0.67",
|
|
32
|
+
"@compill/hooks": "1.0.52",
|
|
33
|
+
"@compill/form": "1.0.75",
|
|
34
|
+
"@compill/models": "1.0.20",
|
|
35
|
+
"@compill/components": "1.0.58"
|
|
43
36
|
},
|
|
44
37
|
"publishConfig": {
|
|
45
38
|
"access": "public"
|
|
@@ -48,7 +41,7 @@
|
|
|
48
41
|
"dist"
|
|
49
42
|
],
|
|
50
43
|
"scripts": {
|
|
51
|
-
"build": "
|
|
44
|
+
"build": "rimraf dist && rollup -c && tsc -p tsconfig.build.json",
|
|
52
45
|
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
53
46
|
"lint": "eslint . --max-warnings 0",
|
|
54
47
|
"check-types": "tsc --noEmit"
|
package/dist/index.d.mts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ButtonBarButtonProps } from '@compill/admin';
|
|
2
|
-
import { API } from '@compill/api';
|
|
3
|
-
import { Location } from '@compill/models';
|
|
4
|
-
|
|
5
|
-
interface NewLocationButtonProps extends ButtonBarButtonProps {
|
|
6
|
-
api: API<Location>;
|
|
7
|
-
lat: number;
|
|
8
|
-
lng: number;
|
|
9
|
-
mapZoom: number;
|
|
10
|
-
locationTypeLabel?: string;
|
|
11
|
-
}
|
|
12
|
-
declare function NewLocationButton({ api, lat, lng, mapZoom, locationTypeLabel, ...props }: NewLocationButtonProps): JSX.Element;
|
|
13
|
-
|
|
14
|
-
interface SidebarMapsCardProps {
|
|
15
|
-
location?: Location;
|
|
16
|
-
}
|
|
17
|
-
declare function SidebarMapsCard({ title, location }: {
|
|
18
|
-
title?: string;
|
|
19
|
-
} & SidebarMapsCardProps): JSX.Element | null;
|
|
20
|
-
|
|
21
|
-
export { NewLocationButton, type NewLocationButtonProps, SidebarMapsCard };
|
package/dist/index.mjs
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { ButtonBarButton, ItemEditDialog } from '@compill/admin';
|
|
2
|
-
import { FormHelper } from '@compill/form';
|
|
3
|
-
import { mapsHelper } from '@compill/form-maps';
|
|
4
|
-
import { useModal, useCopyToClipboard } from '@compill/hooks';
|
|
5
|
-
import { mdiPlus, mdiMapMarker, mdiContentCopy } from '@mdi/js';
|
|
6
|
-
import * as Yup from 'yup';
|
|
7
|
-
import { jsxs, Fragment, jsx } from '@soperio/jsx-runtime';
|
|
8
|
-
import { FlexCenter } from '@compill/components';
|
|
9
|
-
import { NextImageFill } from '@compill/next';
|
|
10
|
-
import { IconButton } from '@valerya/ui';
|
|
11
|
-
import { SidebarCard } from '@brikka/layout';
|
|
12
|
-
|
|
13
|
-
// src/lib/AddLocationButton.tsx
|
|
14
|
-
var editForm = (lat, lng, mapZoom, locationTypeLabel) => FormHelper.array(
|
|
15
|
-
mapsHelper("location", `Search a ${locationTypeLabel}`, lat, lng, mapZoom),
|
|
16
|
-
FormHelper.condition("location", (location) => location != null && Object.keys(location).length > 0, FormHelper.array(
|
|
17
|
-
FormHelper.divider(),
|
|
18
|
-
FormHelper.input("map.addressName", "Name"),
|
|
19
|
-
FormHelper.input("map.addressStreet", "Address", false, void 0, { disabled: true })
|
|
20
|
-
))
|
|
21
|
-
);
|
|
22
|
-
var editInitialValues = () => ({
|
|
23
|
-
type: "google",
|
|
24
|
-
location: {}
|
|
25
|
-
});
|
|
26
|
-
var editSchema = Yup.object().shape({
|
|
27
|
-
// name: Yup.string().required("Please set a name for your organisation"),
|
|
28
|
-
// type: Yup.string().required("Please select a type"),
|
|
29
|
-
});
|
|
30
|
-
function NewLocationButton({ api, lat, lng, mapZoom, locationTypeLabel = "location", ...props }) {
|
|
31
|
-
const { isOpen, onOpen, modalProps } = useModal();
|
|
32
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
33
|
-
/* @__PURE__ */ jsx(ButtonBarButton, { size: "md", icon: mdiPlus, onClick: onOpen, ...props, children: "New Venue" }),
|
|
34
|
-
isOpen && /* @__PURE__ */ jsx(
|
|
35
|
-
ItemEditDialog,
|
|
36
|
-
{
|
|
37
|
-
api,
|
|
38
|
-
form: editForm(lat, lng, mapZoom, locationTypeLabel),
|
|
39
|
-
initialValues: editInitialValues,
|
|
40
|
-
formToQueryData: (values) => ({
|
|
41
|
-
type: "google",
|
|
42
|
-
ext_id: values.map.googleMapsPlaceId,
|
|
43
|
-
lat: values.map.lat,
|
|
44
|
-
lng: values.map.lng,
|
|
45
|
-
name: values.map.addressName,
|
|
46
|
-
address: values.map.addressStreet,
|
|
47
|
-
mapZoom
|
|
48
|
-
}),
|
|
49
|
-
itemLabel: locationTypeLabel,
|
|
50
|
-
formikProps: { validationSchema: editSchema },
|
|
51
|
-
...modalProps
|
|
52
|
-
}
|
|
53
|
-
)
|
|
54
|
-
] });
|
|
55
|
-
}
|
|
56
|
-
function SidebarMapsCard({ title, location }) {
|
|
57
|
-
const copy = useCopyToClipboard(location?.address ?? location?.name ?? "", "Address copied!");
|
|
58
|
-
const googleMapsLink = `https://www.google.com/maps/search/?api=1&query=${location?.lat},${location?.lng}`;
|
|
59
|
-
if (!location)
|
|
60
|
-
return null;
|
|
61
|
-
if (!location.name && !location.address && location.media)
|
|
62
|
-
return null;
|
|
63
|
-
return /* @__PURE__ */ jsx(SidebarCard, { icon: mdiMapMarker, title: title || "Location", children: /* @__PURE__ */ jsxs("div", { bgColor: "white", p: "5", children: [
|
|
64
|
-
(location.name || location.address) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
65
|
-
/* @__PURE__ */ jsxs("div", { ps: "2", dflex: true, alignItems: "center", children: [
|
|
66
|
-
/* @__PURE__ */ jsx("span", { flexGrow: true, children: location.name ? location.name : location.address }),
|
|
67
|
-
/* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(
|
|
68
|
-
IconButton,
|
|
69
|
-
{
|
|
70
|
-
variant: "borderless",
|
|
71
|
-
scheme: "secondary",
|
|
72
|
-
size: "lg",
|
|
73
|
-
rounded: "full",
|
|
74
|
-
icon: mdiContentCopy,
|
|
75
|
-
onClick: copy
|
|
76
|
-
}
|
|
77
|
-
) })
|
|
78
|
-
] }),
|
|
79
|
-
location.name && location.address && /* @__PURE__ */ jsx("div", { ps: "2", textColor: "slate-600", textSize: "sm", children: location.address })
|
|
80
|
-
] }),
|
|
81
|
-
location.media && /* @__PURE__ */ jsxs("div", { aspectRatio: "16/10", group: true, position: "relative", children: [
|
|
82
|
-
/* @__PURE__ */ jsx(
|
|
83
|
-
NextImageFill,
|
|
84
|
-
{
|
|
85
|
-
showLoadingStates: true,
|
|
86
|
-
src: location.media?.url ?? "",
|
|
87
|
-
alt: "Google Maps",
|
|
88
|
-
size: "33vw",
|
|
89
|
-
sm_size: "33vw",
|
|
90
|
-
md_size: "33vw",
|
|
91
|
-
lg_size: "448px",
|
|
92
|
-
xl_size: "448px",
|
|
93
|
-
x2_size: "448px",
|
|
94
|
-
width: location.media?.width ?? 0,
|
|
95
|
-
height: location.media?.height ?? 0
|
|
96
|
-
}
|
|
97
|
-
),
|
|
98
|
-
/* @__PURE__ */ jsx("a", { href: googleMapsLink, target: "_blank", rel: "nofollow", children: /* @__PURE__ */ jsx(
|
|
99
|
-
FlexCenter,
|
|
100
|
-
{
|
|
101
|
-
opacity: "0",
|
|
102
|
-
groupHover_opacity: "100",
|
|
103
|
-
position: "absolute",
|
|
104
|
-
top: "0",
|
|
105
|
-
start: "0",
|
|
106
|
-
w: "full",
|
|
107
|
-
h: "full",
|
|
108
|
-
bgColor: "black",
|
|
109
|
-
bgOpacity: "50",
|
|
110
|
-
textColor: "white",
|
|
111
|
-
fontWeight: "500",
|
|
112
|
-
textSize: "lg",
|
|
113
|
-
transition: "all",
|
|
114
|
-
easing: "in-out",
|
|
115
|
-
duration: "500",
|
|
116
|
-
children: "Open in Google Maps"
|
|
117
|
-
}
|
|
118
|
-
) })
|
|
119
|
-
] })
|
|
120
|
-
] }) });
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export { NewLocationButton, SidebarMapsCard };
|