@bpd-library/components 1.2.8-beta.9 → 1.2.8
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/esm/atoms/button/button.js +33 -0
- package/dist/esm/atoms/button/button.js.map +1 -0
- package/dist/esm/atoms/col/col.js +22 -0
- package/dist/esm/atoms/col/col.js.map +1 -0
- package/dist/esm/atoms/container/container.js +6 -0
- package/dist/esm/atoms/container/container.js.map +1 -0
- package/dist/esm/atoms/form-elements/range-slider/range-slider.js +21 -0
- package/dist/esm/atoms/form-elements/range-slider/range-slider.js.map +1 -0
- package/dist/esm/atoms/form-elements/utilities/range-slider.js +100 -0
- package/dist/esm/atoms/form-elements/utilities/range-slider.js.map +1 -0
- package/dist/esm/atoms/image/image.js +18 -0
- package/dist/esm/atoms/image/image.js.map +1 -0
- package/dist/esm/atoms/image/utilities/create-image-url.js +15 -0
- package/dist/esm/atoms/image/utilities/create-image-url.js.map +1 -0
- package/dist/esm/atoms/row/row.js +6 -0
- package/dist/esm/atoms/row/row.js.map +1 -0
- package/dist/esm/atoms/svg/svg.js +25 -0
- package/dist/esm/atoms/svg/svg.js.map +1 -0
- package/dist/esm/index.js +14 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/molecules/infobox/infobox.js +20 -0
- package/dist/esm/molecules/infobox/infobox.js.map +1 -0
- package/dist/esm/molecules/map/map.js +256 -0
- package/dist/esm/molecules/map/map.js.map +1 -0
- package/dist/esm/molecules/map/store/map/store.js +150 -0
- package/dist/esm/molecules/map/store/map/store.js.map +1 -0
- package/dist/esm/molecules/map/utilities/fit-bounds.js +4 -0
- package/dist/esm/molecules/map/utilities/fit-bounds.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/add-data.js +54 -0
- package/dist/esm/molecules/map/utilities/mapbox/add-data.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/center.js +15 -0
- package/dist/esm/molecules/map/utilities/mapbox/center.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/constants.js +5 -0
- package/dist/esm/molecules/map/utilities/mapbox/constants.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/index.js +3 -0
- package/dist/esm/molecules/map/utilities/mapbox/index.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/mapbox.js +27 -0
- package/dist/esm/molecules/map/utilities/mapbox/mapbox.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/parse-feature-properties.js +18 -0
- package/dist/esm/molecules/map/utilities/mapbox/parse-feature-properties.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/pointers/setup-pointers.js +151 -0
- package/dist/esm/molecules/map/utilities/mapbox/pointers/setup-pointers.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/feature-state.js +11 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/feature-state.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/geojson.js +10 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/geojson.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/interaction.js +34 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/interaction.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/layer.js +110 -0
- package/dist/esm/molecules/map/utilities/mapbox/polygons/layer.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/raster.js +43 -0
- package/dist/esm/molecules/map/utilities/mapbox/raster.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js +27 -0
- package/dist/esm/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/search/search.js +174 -0
- package/dist/esm/molecules/map/utilities/mapbox/search/search.js.map +1 -0
- package/dist/esm/molecules/map/utilities/mapbox/tooltip.js +26 -0
- package/dist/esm/molecules/map/utilities/mapbox/tooltip.js.map +1 -0
- package/dist/esm/molecules/tooltip/tooltip.js +14 -0
- package/dist/esm/molecules/tooltip/tooltip.js.map +1 -0
- package/dist/esm/node_modules/tslib/tslib.es6.js +24 -0
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/lib/atoms/button/button.js +31 -0
- package/dist/lib/atoms/button/button.js.map +1 -0
- package/dist/lib/atoms/button/index.js +2 -0
- package/dist/lib/atoms/button/index.js.map +1 -0
- package/dist/lib/atoms/col/col.js +19 -0
- package/dist/lib/atoms/col/col.js.map +1 -0
- package/dist/lib/atoms/container/container.js +3 -0
- package/dist/lib/atoms/container/container.js.map +1 -0
- package/dist/lib/atoms/form-elements/range-slider/range-slider.js +18 -0
- package/dist/lib/atoms/form-elements/range-slider/range-slider.js.map +1 -0
- package/dist/lib/atoms/form-elements/utilities/range-slider.js +97 -0
- package/dist/lib/atoms/form-elements/utilities/range-slider.js.map +1 -0
- package/dist/lib/atoms/image/image.js +15 -0
- package/dist/lib/atoms/image/image.js.map +1 -0
- package/dist/lib/atoms/image/index.js +2 -0
- package/dist/lib/atoms/image/index.js.map +1 -0
- package/dist/lib/atoms/image/utilities/create-image-url.js +14 -0
- package/dist/lib/atoms/image/utilities/create-image-url.js.map +1 -0
- package/dist/lib/atoms/image/utilities/detect-responsive-images.js +24 -0
- package/dist/lib/atoms/image/utilities/detect-responsive-images.js.map +1 -0
- package/dist/lib/atoms/image/utilities/image.js +86 -0
- package/dist/lib/atoms/image/utilities/image.js.map +1 -0
- package/dist/lib/atoms/image/utilities/object-fit.js +35 -0
- package/dist/lib/atoms/image/utilities/object-fit.js.map +1 -0
- package/dist/lib/atoms/row/row.js +3 -0
- package/dist/lib/atoms/row/row.js.map +1 -0
- package/dist/lib/atoms/svg/svg.js +23 -0
- package/dist/lib/atoms/svg/svg.js.map +1 -0
- package/dist/lib/index.js +12 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/molecules/infobox/index.js +2 -0
- package/dist/lib/molecules/infobox/index.js.map +1 -0
- package/dist/lib/molecules/infobox/infobox.js +17 -0
- package/dist/lib/molecules/infobox/infobox.js.map +1 -0
- package/dist/lib/molecules/map/hooks/use-style-loaded.js +14 -0
- package/dist/lib/molecules/map/hooks/use-style-loaded.js.map +1 -0
- package/dist/lib/molecules/map/index.js +4 -0
- package/dist/lib/molecules/map/index.js.map +1 -0
- package/dist/lib/molecules/map/map.js +256 -0
- package/dist/lib/molecules/map/map.js.map +1 -0
- package/dist/lib/molecules/map/store/map/index.js +2 -0
- package/dist/lib/molecules/map/store/map/index.js.map +1 -0
- package/dist/lib/molecules/map/store/map/store.js +147 -0
- package/dist/lib/molecules/map/store/map/store.js.map +1 -0
- package/dist/lib/molecules/map/storybook/themes.js +54 -0
- package/dist/lib/molecules/map/storybook/themes.js.map +1 -0
- package/dist/lib/molecules/map/utilities/fit-bounds.js +2 -0
- package/dist/lib/molecules/map/utilities/fit-bounds.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/add-data.js +52 -0
- package/dist/lib/molecules/map/utilities/mapbox/add-data.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/center.js +13 -0
- package/dist/lib/molecules/map/utilities/mapbox/center.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/constants.js +3 -0
- package/dist/lib/molecules/map/utilities/mapbox/constants.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/index.js +3 -0
- package/dist/lib/molecules/map/utilities/mapbox/index.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/mapbox.js +25 -0
- package/dist/lib/molecules/map/utilities/mapbox/mapbox.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/parse-feature-properties.js +16 -0
- package/dist/lib/molecules/map/utilities/mapbox/parse-feature-properties.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/pointers/setup-pointers.js +151 -0
- package/dist/lib/molecules/map/utilities/mapbox/pointers/setup-pointers.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/feature-state.js +10 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/feature-state.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/geojson.js +9 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/geojson.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/interaction.js +32 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/interaction.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/layer.js +109 -0
- package/dist/lib/molecules/map/utilities/mapbox/polygons/layer.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/raster.js +42 -0
- package/dist/lib/molecules/map/utilities/mapbox/raster.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js +26 -0
- package/dist/lib/molecules/map/utilities/mapbox/search/alternative-city-suggestions.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/search/search.js +172 -0
- package/dist/lib/molecules/map/utilities/mapbox/search/search.js.map +1 -0
- package/dist/lib/molecules/map/utilities/mapbox/tooltip.js +24 -0
- package/dist/lib/molecules/map/utilities/mapbox/tooltip.js.map +1 -0
- package/dist/lib/molecules/tooltip/index.js +2 -0
- package/dist/lib/molecules/tooltip/index.js.map +1 -0
- package/dist/lib/molecules/tooltip/tooltip.js +11 -0
- package/dist/lib/molecules/tooltip/tooltip.js.map +1 -0
- package/dist/molecules/map/store/map/store.d.ts +7 -1
- package/dist/molecules/map/store/map/store.js +32 -0
- package/dist/molecules/map/store/map/store.js.map +1 -1
- package/dist/types/atoms/button/button.d.ts +17 -0
- package/dist/types/atoms/button/index.d.ts +1 -0
- package/dist/types/atoms/col/col.d.ts +11 -0
- package/dist/types/atoms/container/container.d.ts +6 -0
- package/dist/types/atoms/form-elements/range-slider/range-slider.d.ts +11 -0
- package/dist/types/atoms/form-elements/utilities/range-slider.d.ts +7 -0
- package/dist/types/atoms/image/image.d.ts +14 -0
- package/dist/types/atoms/image/index.d.ts +1 -0
- package/dist/types/atoms/image/utilities/create-image-url.d.ts +6 -0
- package/dist/types/atoms/image/utilities/detect-responsive-images.d.ts +7 -0
- package/dist/types/atoms/image/utilities/image.d.ts +18 -0
- package/dist/types/atoms/image/utilities/object-fit.d.ts +7 -0
- package/dist/types/atoms/row/row.d.ts +6 -0
- package/dist/types/atoms/svg/svg.d.ts +4 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/molecules/infobox/index.d.ts +1 -0
- package/dist/types/molecules/infobox/infobox.d.ts +7 -0
- package/dist/types/molecules/map/hooks/use-style-loaded.d.ts +2 -0
- package/dist/types/molecules/map/index.d.ts +3 -0
- package/dist/types/molecules/map/map.d.ts +2 -0
- package/dist/types/molecules/map/store/map/index.d.ts +1 -0
- package/dist/types/molecules/map/store/map/store.d.ts +60 -0
- package/dist/types/molecules/map/storybook/themes.d.ts +3 -0
- package/dist/types/molecules/map/utilities/fit-bounds.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/add-data.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/center.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/constants.d.ts +2 -0
- package/dist/types/molecules/map/utilities/mapbox/index.d.ts +2 -0
- package/dist/types/molecules/map/utilities/mapbox/mapbox.d.ts +16 -0
- package/dist/types/molecules/map/utilities/mapbox/parse-feature-properties.d.ts +6 -0
- package/dist/types/molecules/map/utilities/mapbox/pointers/setup-pointers.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/polygons/feature-state.d.ts +2 -0
- package/dist/types/molecules/map/utilities/mapbox/polygons/geojson.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/polygons/interaction.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/polygons/layer.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/raster.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/search/alternative-city-suggestions.d.ts +3 -0
- package/dist/types/molecules/map/utilities/mapbox/search/search.d.ts +4 -0
- package/dist/types/molecules/map/utilities/mapbox/tooltip.d.ts +4 -0
- package/dist/types/molecules/tooltip/index.d.ts +1 -0
- package/dist/types/molecules/tooltip/tooltip.d.ts +7 -0
- package/package.json +4 -4
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { h } from '@atomify/jsx';
|
|
2
|
+
|
|
3
|
+
const createClassName = (data) => {
|
|
4
|
+
let className = data.variant ? `c-button--${data.variant}` : 'c-button';
|
|
5
|
+
className += data.icon ? ' button--icon' : '';
|
|
6
|
+
className += data.size ? ` button--${data.size}` : '';
|
|
7
|
+
className += data.classes ? ` ${data.classes}` : '';
|
|
8
|
+
return className;
|
|
9
|
+
};
|
|
10
|
+
const createAttributes = (data) => {
|
|
11
|
+
const attributes = Object.assign(Object.assign({}, data.attr), { [`js-hook-${data.hook}`]: data.hook, onClick: data.onClick, ariaControls: data.controls, href: data.url });
|
|
12
|
+
return attributes;
|
|
13
|
+
};
|
|
14
|
+
const Button = (data) => {
|
|
15
|
+
const className = createClassName(data);
|
|
16
|
+
const attributes = createAttributes(data);
|
|
17
|
+
attributes.type = data.type || 'button';
|
|
18
|
+
return (h("button", Object.assign({ class: className }, attributes),
|
|
19
|
+
data.icon && (h("span", { class: "button__icon" },
|
|
20
|
+
h("bpd-svg", { name: data.icon }))),
|
|
21
|
+
h("span", { class: "button__label" }, data.label)));
|
|
22
|
+
};
|
|
23
|
+
const ButtonA = (data) => {
|
|
24
|
+
const className = createClassName(data);
|
|
25
|
+
const attributes = createAttributes(data);
|
|
26
|
+
return (h("a", Object.assign({ class: className }, attributes, { target: data.target }),
|
|
27
|
+
data.icon && (h("span", { class: "button__icon" },
|
|
28
|
+
h("bpd-svg", { name: data.icon }))),
|
|
29
|
+
h("span", { class: "button__label" }, data.label)));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { Button, ButtonA };
|
|
33
|
+
//# sourceMappingURL=button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.js","sources":["../../../../src/atoms/button/button.tsx"],"sourcesContent":["import { h } from '@atomify/jsx';\n\ninterface ButtonInterface {\n label: string | Text;\n variant?: string;\n icon?: string;\n size?: string;\n classes?: string;\n type?: string;\n url?: string;\n hook?: string;\n controls?: string;\n onClick?: Function;\n target?: string;\n attr?: {};\n}\n\nconst createClassName = (data: ButtonInterface) => {\n let className = data.variant ? `c-button--${data.variant}` : 'c-button';\n\n className += data.icon ? ' button--icon' : '';\n className += data.size ? ` button--${data.size}` : '';\n className += data.classes ? ` ${data.classes}` : '';\n\n return className;\n};\n\nconst createAttributes = (data: ButtonInterface) => {\n const attributes: any = {\n ...data.attr,\n [`js-hook-${data.hook}`]: data.hook,\n onClick: data.onClick,\n ariaControls: data.controls,\n href: data.url,\n };\n\n return attributes;\n};\n\n/*\n <button> element\n*/\nconst Button = (data: ButtonInterface) => {\n const className = createClassName(data);\n const attributes = createAttributes(data);\n\n attributes.type = data.type || 'button';\n\n return (\n <button class={className} {...attributes}>\n {data.icon && (\n <span class=\"button__icon\">\n <bpd-svg name={data.icon}></bpd-svg>\n </span>\n )}\n\n <span class=\"button__label\">{data.label}</span>\n </button>\n );\n};\n\n/*\n <a> element\n*/\nconst ButtonA = (data: ButtonInterface) => {\n const className = createClassName(data);\n const attributes = createAttributes(data);\n\n return (\n <a class={className} {...attributes} target={data.target}>\n {data.icon && (\n <span class=\"button__icon\">\n <bpd-svg name={data.icon}></bpd-svg>\n </span>\n )}\n\n <span class=\"button__label\">{data.label}</span>\n </a>\n );\n};\n\nexport { Button, ButtonA };\n"],"names":[],"mappings":";;AAiBA,MAAM,eAAe,GAAG,CAAC,IAAqB;IAC1C,IAAI,SAAS,GAAG,IAAI,CAAC,OAAO,GAAG,aAAa,IAAI,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC;IAExE,SAAS,IAAI,IAAI,CAAC,IAAI,GAAG,eAAe,GAAG,EAAE,CAAC;IAC9C,SAAS,IAAI,IAAI,CAAC,IAAI,GAAG,YAAY,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC;IACtD,SAAS,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC;IAEpD,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,IAAqB;IAC3C,MAAM,UAAU,mCACT,IAAI,CAAC,IAAI,KACZ,CAAC,WAAW,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,EACnC,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,YAAY,EAAE,IAAI,CAAC,QAAQ,EAC3B,IAAI,EAAE,IAAI,CAAC,GAAG,GACjB,CAAC;IAEF,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;MAKI,MAAM,GAAG,CAAC,IAAqB;IACjC,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE1C,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC;IAExC,QACI,4BAAQ,KAAK,EAAE,SAAS,IAAM,UAAU;QACnC,IAAI,CAAC,IAAI,KACN,YAAM,KAAK,EAAC,cAAc;YACtB,eAAS,IAAI,EAAE,IAAI,CAAC,IAAI,GAAY,CACjC,CACV;QAED,YAAM,KAAK,EAAC,eAAe,IAAE,IAAI,CAAC,KAAK,CAAQ,CAC1C,EACX;AACN,EAAE;MAKI,OAAO,GAAG,CAAC,IAAqB;IAClC,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE1C,QACI,uBAAG,KAAK,EAAE,SAAS,IAAM,UAAU,IAAE,MAAM,EAAE,IAAI,CAAC,MAAM;QACnD,IAAI,CAAC,IAAI,KACN,YAAM,KAAK,EAAC,cAAc;YACtB,eAAS,IAAI,EAAE,IAAI,CAAC,IAAI,GAAY,CACjC,CACV;QAED,YAAM,KAAK,EAAC,eAAe,IAAE,IAAI,CAAC,KAAK,CAAQ,CAC/C,EACN;AACN;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { h } from '@atomify/jsx';
|
|
2
|
+
|
|
3
|
+
const breakpoints = ['xs', 'sm', 'md', 'lg', 'xlg'];
|
|
4
|
+
const createClasses = (prefix, cols) => {
|
|
5
|
+
return cols.reduce((classes, col, i) => {
|
|
6
|
+
classes.push(i === 0 ? `${prefix}-${col}` : `${prefix}-${col}--${breakpoints[i]}`);
|
|
7
|
+
return classes;
|
|
8
|
+
}, []);
|
|
9
|
+
};
|
|
10
|
+
const Col = ({ extraClass = '', children, cols = [], push = [], pull = [], pre = [], post = [], }) => {
|
|
11
|
+
const classes = [
|
|
12
|
+
...createClasses('o-col', cols),
|
|
13
|
+
...createClasses('u-push', push),
|
|
14
|
+
...createClasses('u-pull', pull),
|
|
15
|
+
...createClasses('u-pre', pre),
|
|
16
|
+
...createClasses('u-post', post),
|
|
17
|
+
].join(' ');
|
|
18
|
+
return h("div", { class: `${classes} ${extraClass}` }, children);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { Col };
|
|
22
|
+
//# sourceMappingURL=col.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"col.js","sources":["../../../../src/atoms/col/col.tsx"],"sourcesContent":["import { h } from '@atomify/jsx';\n\nconst breakpoints: string[] = ['xs', 'sm', 'md', 'lg', 'xlg'];\n\nconst createClasses = (prefix: string, cols: (number | undefined)[]) => {\n return cols.reduce((classes: string[], col, i) => {\n classes.push(i === 0 ? `${prefix}-${col}` : `${prefix}-${col}--${breakpoints[i]}`);\n\n return classes;\n }, []);\n};\n\ninterface ColInterface {\n extraClass?: string;\n children?: NodeList;\n cols?: (number | undefined)[];\n push?: (number | undefined)[];\n pull?: (number | undefined)[];\n pre?: (number | undefined)[];\n post?: (number | undefined)[];\n}\n\n/**\n * @param {ColInterface} {\n * extraClass = '',\n * children,\n * cols = [],\n * push = [],\n * pull = [],\n * pre = [],\n * post = [],\n * }\n * @returns {Node}\n */\nexport const Col = ({\n extraClass = '',\n children,\n cols = [],\n push = [],\n pull = [],\n pre = [],\n post = [],\n}: ColInterface) => {\n const classes: string = [\n ...createClasses('o-col', cols),\n ...createClasses('u-push', push),\n ...createClasses('u-pull', pull),\n ...createClasses('u-pre', pre),\n ...createClasses('u-post', post),\n ].join(' ');\n\n return <div class={`${classes} ${extraClass}`}>{children}</div>;\n};\n"],"names":[],"mappings":";;AAEA,MAAM,WAAW,GAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAE9D,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,IAA4B;IAC/D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,OAAiB,EAAE,GAAG,EAAE,CAAC;QACzC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,IAAI,GAAG,EAAE,GAAG,GAAG,MAAM,IAAI,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAEnF,OAAO,OAAO,CAAC;KAClB,EAAE,EAAE,CAAC,CAAC;AACX,CAAC,CAAC;MAwBW,GAAG,GAAG,CAAC,EAChB,UAAU,GAAG,EAAE,EACf,QAAQ,EACR,IAAI,GAAG,EAAE,EACT,IAAI,GAAG,EAAE,EACT,IAAI,GAAG,EAAE,EACT,GAAG,GAAG,EAAE,EACR,IAAI,GAAG,EAAE,GACE;IACX,MAAM,OAAO,GAAW;QACpB,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC;QAC/B,GAAG,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC;QAChC,GAAG,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC;QAChC,GAAG,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC;QAC9B,GAAG,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC;KACnC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,OAAO,WAAK,KAAK,EAAE,GAAG,OAAO,IAAI,UAAU,EAAE,IAAG,QAAQ,CAAO,CAAC;AACpE;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.js","sources":["../../../../src/atoms/container/container.tsx"],"sourcesContent":["import { h } from '@atomify/jsx';\n\ninterface ContainerInterface {\n extraClass?: string;\n children?: NodeList;\n}\n\nexport const Container = ({ extraClass = '', children }: ContainerInterface) => (\n <div class={`o-container ${extraClass}`}>{children}</div>\n);\n"],"names":[],"mappings":";;MAOa,SAAS,GAAG,CAAC,EAAE,UAAU,GAAG,EAAE,EAAE,QAAQ,EAAsB,MACvE,WAAK,KAAK,EAAE,eAAe,UAAU,EAAE,IAAG,QAAQ,CAAO;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { h } from '@atomify/jsx';
|
|
2
|
+
|
|
3
|
+
const RangeSliderElement = ({ classes, disabled, min, max, increment, start, name, onChange, }) => {
|
|
4
|
+
const inputClasses = {
|
|
5
|
+
['c-range-slider']: true,
|
|
6
|
+
['form__item']: true,
|
|
7
|
+
['form__item--disabled']: disabled,
|
|
8
|
+
};
|
|
9
|
+
return (h("div", { class: inputClasses },
|
|
10
|
+
h("bpd-range-slider", { min: min, max: max, increment: increment, start: start, onRangeValuesChanged: onChange, class: classes },
|
|
11
|
+
h("div", { class: "range-slider__container" },
|
|
12
|
+
h("div", { "js-hook-slider-container": true }),
|
|
13
|
+
h("div", { class: "range-slider__values" },
|
|
14
|
+
h("span", { class: "range-slider__values-item", "js-hook-slider-min": true }),
|
|
15
|
+
h("span", { class: "range-slider__values-item", "js-hook-slider-max": true }),
|
|
16
|
+
h("input", { type: "number", id: `${name}-0`, name: name, value: start[0], "js-hook-slider-min-value": true }),
|
|
17
|
+
h("input", { type: "number", id: `${name}-1`, name: name, value: start[1], "js-hook-slider-max-value": true }))))));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { RangeSliderElement };
|
|
21
|
+
//# sourceMappingURL=range-slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider.js","sources":["../../../../../src/atoms/form-elements/range-slider/range-slider.tsx"],"sourcesContent":["import { h } from '@atomify/jsx';\n\nexport interface RangeSliderProps {\n min: number;\n max: number;\n increment: number;\n start: number[];\n onChange: (e: CustomEvent) => void;\n name: string;\n classes?: string;\n disabled?: boolean;\n}\n\nexport const RangeSliderElement = ({\n classes,\n disabled,\n min,\n max,\n increment,\n start,\n name,\n onChange,\n}: RangeSliderProps) => {\n const inputClasses = {\n ['c-range-slider']: true,\n ['form__item']: true,\n ['form__item--disabled']: disabled,\n };\n\n return (\n <div class={inputClasses}>\n <bpd-range-slider\n min={min}\n max={max}\n increment={increment}\n start={start}\n onRangeValuesChanged={onChange}\n class={classes}>\n <div class=\"range-slider__container\">\n <div js-hook-slider-container></div>\n <div class=\"range-slider__values\">\n <span class=\"range-slider__values-item\" js-hook-slider-min></span>\n <span class=\"range-slider__values-item\" js-hook-slider-max></span>\n <input\n type=\"number\"\n id={`${name}-0`}\n name={name}\n value={start[0]}\n js-hook-slider-min-value\n />\n <input\n type=\"number\"\n id={`${name}-1`}\n name={name}\n value={start[1]}\n js-hook-slider-max-value\n />\n </div>\n </div>\n </bpd-range-slider>\n </div>\n );\n};\n"],"names":[],"mappings":";;MAaa,kBAAkB,GAAG,CAAC,EAC/B,OAAO,EACP,QAAQ,EACR,GAAG,EACH,GAAG,EACH,SAAS,EACT,KAAK,EACL,IAAI,EACJ,QAAQ,GACO;IACf,MAAM,YAAY,GAAG;QACjB,CAAC,gBAAgB,GAAG,IAAI;QACxB,CAAC,YAAY,GAAG,IAAI;QACpB,CAAC,sBAAsB,GAAG,QAAQ;KACrC,CAAC;IAEF,QACI,WAAK,KAAK,EAAE,YAAY;QACpB,wBACI,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,oBAAoB,EAAE,QAAQ,EAC9B,KAAK,EAAE,OAAO;YACd,WAAK,KAAK,EAAC,yBAAyB;gBAChC,8CAAoC;gBACpC,WAAK,KAAK,EAAC,sBAAsB;oBAC7B,YAAM,KAAK,EAAC,2BAA2B,+BAA2B;oBAClE,YAAM,KAAK,EAAC,2BAA2B,+BAA2B;oBAClE,aACI,IAAI,EAAC,QAAQ,EACb,EAAE,EAAE,GAAG,IAAI,IAAI,EACf,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,qCAEjB;oBACF,aACI,IAAI,EAAC,QAAQ,EACb,EAAE,EAAE,GAAG,IAAI,IAAI,EACf,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,qCAEjB,CACA,CACJ,CACS,CACjB,EACR;AACN;;;;"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { defineElement, useProp, useElement, useEvent, useBindMethod, onDidLoad } from '@atomify/hooks';
|
|
2
|
+
import { toCurrency } from '@bpd-library/utilities';
|
|
3
|
+
import noUiSlider from 'nouislider';
|
|
4
|
+
|
|
5
|
+
const RangeSlider = ({ element }) => {
|
|
6
|
+
const [min] = useProp('min', 0);
|
|
7
|
+
const [max] = useProp('max', 0);
|
|
8
|
+
const [increment] = useProp('increment', 0);
|
|
9
|
+
const [hasChanged, setHasChanged] = useProp('hasChanged', false);
|
|
10
|
+
const [, setStart, watchStart] = useProp('start', [0, 0]);
|
|
11
|
+
const [, setBindValue] = useProp('bindValue', [0, 0]);
|
|
12
|
+
const sliderContainer = useElement('[js-hook-slider-container]');
|
|
13
|
+
const sliderMin = useElement('[js-hook-slider-min]');
|
|
14
|
+
const sliderMax = useElement('[js-hook-slider-max]');
|
|
15
|
+
const sliderMinValue = useElement('[js-hook-slider-min-value]');
|
|
16
|
+
const sliderMaxValue = useElement('[js-hook-slider-max-value]');
|
|
17
|
+
const rangeValuesChanged = useEvent({ eventName: 'rangevalueschanged' });
|
|
18
|
+
useBindMethod('resetState', resetState);
|
|
19
|
+
onDidLoad(() => {
|
|
20
|
+
const hasZeroValues = element.start.every((item) => item === 0);
|
|
21
|
+
const settings = {
|
|
22
|
+
start: hasZeroValues ? [min, max] : element.start,
|
|
23
|
+
step: increment,
|
|
24
|
+
connect: true,
|
|
25
|
+
documentElement: sliderContainer.current,
|
|
26
|
+
range: {
|
|
27
|
+
min,
|
|
28
|
+
max,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
noUiSlider.create(sliderContainer.current, settings);
|
|
32
|
+
sliderContainer.current.noUiSlider.on('update', (values) => {
|
|
33
|
+
const generatedValues = values.map((value) => parseInt(value));
|
|
34
|
+
setStart([...generatedValues]);
|
|
35
|
+
});
|
|
36
|
+
sliderContainer.current.noUiSlider.on('change', onChangeHandler);
|
|
37
|
+
setMinMaxValues();
|
|
38
|
+
});
|
|
39
|
+
watchStart(setMinMaxValues);
|
|
40
|
+
function setMinMaxValues() {
|
|
41
|
+
const { minValue, maxValue } = getValues();
|
|
42
|
+
sliderMin.current.innerHTML = `${toCurrency(minValue)}`.replace(',', '.');
|
|
43
|
+
sliderMax.current.innerHTML = `${toCurrency(maxValue)}`.replace(',', '.');
|
|
44
|
+
}
|
|
45
|
+
function onChangeHandler() {
|
|
46
|
+
const { minValue, maxValue } = getValues();
|
|
47
|
+
sliderMinValue.current.value = `${minValue}`;
|
|
48
|
+
sliderMaxValue.current.value = `${maxValue}`;
|
|
49
|
+
sliderMinValue.current.checked = true;
|
|
50
|
+
sliderMaxValue.current.checked = true;
|
|
51
|
+
sliderMinValue.current.dispatchEvent(new Event('change'));
|
|
52
|
+
sliderMaxValue.current.dispatchEvent(new Event('change'));
|
|
53
|
+
rangeValuesChanged.emit({ minValue, maxValue, hasChanged });
|
|
54
|
+
}
|
|
55
|
+
function getValues() {
|
|
56
|
+
const hasZeroValues = element.start.every((item) => item === 0);
|
|
57
|
+
const minValue = hasZeroValues ? min : element.start[0];
|
|
58
|
+
const maxValue = hasZeroValues ? max : element.start[1];
|
|
59
|
+
setBindValue(element.start);
|
|
60
|
+
setHasChanged(JSON.stringify(element.start) !== JSON.stringify([min, max]));
|
|
61
|
+
return {
|
|
62
|
+
minValue,
|
|
63
|
+
maxValue,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function resetState() {
|
|
67
|
+
sliderContainer.current.noUiSlider.set([min, max]);
|
|
68
|
+
setStart([0, 0]);
|
|
69
|
+
setHasChanged(false);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
RangeSlider.props = {
|
|
73
|
+
min: {
|
|
74
|
+
type: Number,
|
|
75
|
+
reflectToAttr: true,
|
|
76
|
+
},
|
|
77
|
+
max: {
|
|
78
|
+
type: Number,
|
|
79
|
+
reflectToAttr: true,
|
|
80
|
+
},
|
|
81
|
+
increment: {
|
|
82
|
+
type: Number,
|
|
83
|
+
reflectToAttr: true,
|
|
84
|
+
},
|
|
85
|
+
hasChanged: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
reflectToAttr: true,
|
|
88
|
+
},
|
|
89
|
+
start: {
|
|
90
|
+
type: Array,
|
|
91
|
+
reflectToAttr: true,
|
|
92
|
+
},
|
|
93
|
+
bindValue: {
|
|
94
|
+
type: Array,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
defineElement('bpd-range-slider', RangeSlider);
|
|
98
|
+
|
|
99
|
+
export { RangeSlider };
|
|
100
|
+
//# sourceMappingURL=range-slider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-slider.js","sources":["../../../../../src/atoms/form-elements/utilities/range-slider.ts"],"sourcesContent":["import {\n Component,\n defineElement,\n FC,\n onDidLoad,\n useBindMethod,\n useElement,\n useEvent,\n useProp,\n} from '@atomify/hooks';\nimport { toCurrency } from '@bpd-library/utilities';\nimport noUiSlider from 'nouislider';\n\nexport interface BPDRange extends Component {\n bindValue: number[];\n start: number[];\n resetState: () => void;\n}\n\nexport const RangeSlider: FC<BPDRange> = ({ element }) => {\n const [min] = useProp<number>('min', 0);\n const [max] = useProp<number>('max', 0);\n const [increment] = useProp<number>('increment', 0);\n const [hasChanged, setHasChanged] = useProp<boolean>('hasChanged', false);\n const [, setStart, watchStart] = useProp<number[]>('start', [0, 0]);\n const [, setBindValue] = useProp<number[]>('bindValue', [0, 0]);\n\n const sliderContainer = useElement<HTMLDivElement>('[js-hook-slider-container]');\n const sliderMin = useElement<HTMLDivElement>('[js-hook-slider-min]');\n const sliderMax = useElement<HTMLDivElement>('[js-hook-slider-max]');\n const sliderMinValue = useElement<HTMLInputElement>('[js-hook-slider-min-value]');\n const sliderMaxValue = useElement<HTMLInputElement>('[js-hook-slider-max-value]');\n\n const rangeValuesChanged = useEvent({ eventName: 'rangevalueschanged' });\n\n useBindMethod('resetState', resetState);\n\n onDidLoad(() => {\n const hasZeroValues = element.start.every((item) => item === 0);\n\n const settings = {\n start: hasZeroValues ? [min, max] : element.start,\n step: increment,\n connect: true,\n documentElement: sliderContainer.current,\n range: {\n min,\n max,\n },\n };\n\n noUiSlider.create(sliderContainer.current!, settings);\n\n (sliderContainer.current as any).noUiSlider.on('update', (values: string[]) => {\n const generatedValues = values.map((value) => parseInt(value));\n setStart([...generatedValues]);\n });\n\n (sliderContainer.current as any).noUiSlider.on('change', onChangeHandler);\n\n setMinMaxValues();\n });\n\n watchStart(setMinMaxValues);\n\n function setMinMaxValues() {\n const { minValue, maxValue } = getValues();\n\n sliderMin.current!.innerHTML = `${toCurrency(minValue)}`.replace(',', '.');\n sliderMax.current!.innerHTML = `${toCurrency(maxValue)}`.replace(',', '.');\n }\n\n function onChangeHandler() {\n const { minValue, maxValue } = getValues();\n\n sliderMinValue.current!.value = `${minValue}`;\n sliderMaxValue.current!.value = `${maxValue}`;\n\n sliderMinValue.current!.checked = true;\n sliderMaxValue.current!.checked = true;\n\n sliderMinValue.current!.dispatchEvent(new Event('change'));\n sliderMaxValue.current!.dispatchEvent(new Event('change'));\n\n rangeValuesChanged.emit({ minValue, maxValue, hasChanged });\n }\n\n function getValues() {\n const hasZeroValues = element.start.every((item) => item === 0);\n const minValue = hasZeroValues ? min : element.start[0];\n const maxValue = hasZeroValues ? max : element.start[1];\n\n setBindValue(element.start);\n setHasChanged(JSON.stringify(element.start) !== JSON.stringify([min, max]));\n\n return {\n minValue,\n maxValue,\n };\n }\n\n function resetState() {\n (sliderContainer.current as any).noUiSlider.set([min, max]);\n setStart([0, 0]);\n setHasChanged(false);\n }\n};\n\nRangeSlider.props = {\n min: {\n type: Number,\n reflectToAttr: true,\n },\n max: {\n type: Number,\n reflectToAttr: true,\n },\n increment: {\n type: Number,\n reflectToAttr: true,\n },\n hasChanged: {\n type: Boolean,\n reflectToAttr: true,\n },\n start: {\n type: Array,\n reflectToAttr: true,\n },\n bindValue: {\n type: Array,\n },\n};\n\ndefineElement('bpd-range-slider', RangeSlider);\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { h } from '@atomify/jsx';
|
|
2
|
+
import createImageUrl from './utilities/create-image-url.js';
|
|
3
|
+
|
|
4
|
+
const Image = (data) => {
|
|
5
|
+
const preload = data.preload ? createImageUrl(data.image, data.preload) : false;
|
|
6
|
+
return (h("bpd-image", { class: `c-image ${data.classes ? data.classes : ''}` },
|
|
7
|
+
h("figure", Object.assign({}, { 'js-hook-objectfit-container': data.objectFit }),
|
|
8
|
+
h("img", Object.assign({ class: `${data.disableCrossFade ? '' : ' image__default'}`, "data-image": data.image, alt: data.alt }, {
|
|
9
|
+
src: preload ? preload : false,
|
|
10
|
+
'data-settings': JSON.stringify(data.settings),
|
|
11
|
+
'js-hook-objectfit-img': data.objectFit,
|
|
12
|
+
hidden: data.hidden,
|
|
13
|
+
}))),
|
|
14
|
+
data.caption && h("figcaption", { class: "image__caption" }, data.caption)));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Image };
|
|
18
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sources":["../../../../src/atoms/image/image.tsx"],"sourcesContent":["import { h } from '@atomify/jsx';\n\nimport createImageUrl from './utilities/create-image-url';\nimport { Setting, Settings } from './utilities/image';\n\nexport interface ImageInterface {\n image: string;\n alt: string;\n\n settings?: Settings;\n preload?: Setting;\n\n // Remove after settings is implemented\n srcset?: string;\n\n classes?: string;\n caption?: string;\n\n hidden?: boolean;\n objectFit?: boolean | 'contain';\n disableCrossFade?: boolean;\n}\n\nexport const Image = (data: ImageInterface) => {\n const preload = data.preload ? createImageUrl(data.image, data.preload) : false;\n\n return (\n <bpd-image class={`c-image ${data.classes ? data.classes : ''}`}>\n <figure {...{ 'js-hook-objectfit-container': data.objectFit }}>\n <img\n class={`${data.disableCrossFade ? '' : ' image__default'}`}\n data-image={data.image}\n alt={data.alt}\n {...{\n src: preload ? preload : false,\n 'data-settings': JSON.stringify(data.settings),\n 'js-hook-objectfit-img': data.objectFit,\n hidden: data.hidden,\n }}\n />\n </figure>\n\n {data.caption && <figcaption class=\"image__caption\">{data.caption}</figcaption>}\n </bpd-image>\n );\n};\n"],"names":[],"mappings":";;;MAuBa,KAAK,GAAG,CAAC,IAAoB;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;IAEhF,QACI,iBAAW,KAAK,EAAE,WAAW,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,EAAE,EAAE;QAC3D,8BAAY,EAAE,6BAA6B,EAAE,IAAI,CAAC,SAAS,EAAE;YACzD,yBACI,KAAK,EAAE,GAAG,IAAI,CAAC,gBAAgB,GAAG,EAAE,GAAG,iBAAiB,EAAE,gBAC9C,IAAI,CAAC,KAAK,EACtB,GAAG,EAAE,IAAI,CAAC,GAAG,IACT;gBACA,GAAG,EAAE,OAAO,GAAG,OAAO,GAAG,KAAK;gBAC9B,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAC9C,uBAAuB,EAAE,IAAI,CAAC,SAAS;gBACvC,MAAM,EAAE,IAAI,CAAC,MAAM;aACtB,EACH,CACG;QAER,IAAI,CAAC,OAAO,IAAI,kBAAY,KAAK,EAAC,gBAAgB,IAAE,IAAI,CAAC,OAAO,CAAc,CACvE,EACd;AACN;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const addUrlParameter = (url, key, value) => {
|
|
2
|
+
const separator = url.indexOf('?') > -1 ? '&' : '?';
|
|
3
|
+
return `${url}${separator}${key}=${value}`;
|
|
4
|
+
};
|
|
5
|
+
const createImageUrl = (image, { width, height }) => {
|
|
6
|
+
let url = addUrlParameter(image, 'mode', 'crop');
|
|
7
|
+
if (width)
|
|
8
|
+
url = addUrlParameter(url, 'width', width);
|
|
9
|
+
if (height)
|
|
10
|
+
url = addUrlParameter(url, 'height', height);
|
|
11
|
+
return url;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { createImageUrl as default };
|
|
15
|
+
//# sourceMappingURL=create-image-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-image-url.js","sources":["../../../../../src/atoms/image/utilities/create-image-url.ts"],"sourcesContent":["interface Setting {\n width?: number;\n height?: number;\n}\n\nconst addUrlParameter = (url: string, key: string, value: string | number) => {\n const separator = url.indexOf('?') > -1 ? '&' : '?';\n\n return `${url}${separator}${key}=${value}`;\n};\n\nconst createImageUrl = (image: string, { width, height }: Setting) => {\n let url = addUrlParameter(image, 'mode', 'crop');\n\n if (width) url = addUrlParameter(url, 'width', width);\n if (height) url = addUrlParameter(url, 'height', height);\n\n return url;\n};\n\nexport default createImageUrl;\n"],"names":[],"mappings":"AAKA,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,KAAsB;IACrE,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC;IAEpD,OAAO,GAAG,GAAG,GAAG,SAAS,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;AAC/C,CAAC,CAAC;MAEI,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE,KAAK,EAAE,MAAM,EAAW;IAC7D,IAAI,GAAG,GAAG,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjD,IAAI,KAAK;QAAE,GAAG,GAAG,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACtD,IAAI,MAAM;QAAE,GAAG,GAAG,eAAe,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAEzD,OAAO,GAAG,CAAC;AACf;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row.js","sources":["../../../../src/atoms/row/row.tsx"],"sourcesContent":["import { h } from '@atomify/jsx';\n\ninterface RowInterface {\n extraClass?: string;\n children?: NodeList;\n}\n\nexport const Row = ({ extraClass = '', children }: RowInterface) => (\n <div class={`o-grid ${extraClass}`}>{children}</div>\n);\n"],"names":[],"mappings":";;MAOa,GAAG,GAAG,CAAC,EAAE,UAAU,GAAG,EAAE,EAAE,QAAQ,EAAgB,MAC3D,WAAK,KAAK,EAAE,UAAU,UAAU,EAAE,IAAG,QAAQ,CAAO;;;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { __decorate } from '../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { Prop, Component } from '@atomify/core';
|
|
3
|
+
import { h } from '@atomify/jsx';
|
|
4
|
+
|
|
5
|
+
let BPDSvg = class BPDSvg extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.name = '';
|
|
9
|
+
}
|
|
10
|
+
render() {
|
|
11
|
+
return (h("svg", { class: `svg svg-${this.name}` },
|
|
12
|
+
h("use", { xlinkHref: `#svg-${this.name}` })));
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
__decorate([
|
|
16
|
+
Prop()
|
|
17
|
+
], BPDSvg.prototype, "name", void 0);
|
|
18
|
+
BPDSvg = __decorate([
|
|
19
|
+
Component({
|
|
20
|
+
tag: 'bpd-svg',
|
|
21
|
+
})
|
|
22
|
+
], BPDSvg);
|
|
23
|
+
|
|
24
|
+
export { BPDSvg };
|
|
25
|
+
//# sourceMappingURL=svg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.js","sources":["../../../../src/atoms/svg/svg.tsx"],"sourcesContent":["import { Component, Prop } from '@atomify/core';\nimport { h } from '@atomify/jsx';\n\n@Component({\n tag: 'bpd-svg',\n})\nexport class BPDSvg extends HTMLElement {\n @Prop() name: string = '';\n\n render() {\n return (\n <svg class={`svg svg-${this.name}`}>\n <use xlinkHref={`#svg-${this.name}`}></use>\n </svg>\n );\n }\n}\n"],"names":[],"mappings":";;;;IAMa,MAAM,GAAnB,MAAa,MAAO,SAAQ,WAAW;IAAvC;;QACY,SAAI,GAAW,EAAE,CAAC;KAS7B;IAPG,MAAM;QACF,QACI,WAAK,KAAK,EAAE,WAAW,IAAI,CAAC,IAAI,EAAE;YAC9B,WAAK,SAAS,EAAE,QAAQ,IAAI,CAAC,IAAI,EAAE,GAAQ,CACzC,EACR;KACL;EACJ;AATW;IAAP,IAAI,EAAE;oCAAmB;AADjB,MAAM;IAHlB,SAAS,CAAC;QACP,GAAG,EAAE,SAAS;KACjB,CAAC;GACW,MAAM,CAUlB;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { Button, ButtonA } from './atoms/button/button.js';
|
|
2
|
+
export { Col } from './atoms/col/col.js';
|
|
3
|
+
export { Container } from './atoms/container/container.js';
|
|
4
|
+
export { RangeSliderElement } from './atoms/form-elements/range-slider/range-slider.js';
|
|
5
|
+
export { RangeSlider } from './atoms/form-elements/utilities/range-slider.js';
|
|
6
|
+
export { Image } from './atoms/image/image.js';
|
|
7
|
+
export { Row } from './atoms/row/row.js';
|
|
8
|
+
export { BPDSvg } from './atoms/svg/svg.js';
|
|
9
|
+
export { Infobox } from './molecules/infobox/infobox.js';
|
|
10
|
+
export { fitBounds } from './molecules/map/utilities/fit-bounds.js';
|
|
11
|
+
export { clearFilter, clearFocus, clearHover, clearSearchResult, getHover, getMapInstance, getMapboxData, getSearchIsMoving, manualSearch, mapStore, setFilter, setFocus, setLayerRaster, setMapInstance, updateClick, updateHover, updateMapData, updateSearchIsMoving, updateSearchResult } from './molecules/map/store/map/store.js';
|
|
12
|
+
export { Map } from './molecules/map/map.js';
|
|
13
|
+
export { Tooltip } from './molecules/tooltip/tooltip.js';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { h } from '@atomify/jsx';
|
|
2
|
+
import { ButtonA } from '../../atoms/button/button.js';
|
|
3
|
+
import { Image } from '../../atoms/image/image.js';
|
|
4
|
+
|
|
5
|
+
const Infobox = ({ title, image, tags, description, link, onClose, openInTab, }) => (h("div", { class: "c-infobox" },
|
|
6
|
+
h("button", { class: "infobox__close", onClick: onClose },
|
|
7
|
+
h("bpd-svg", { name: "icons-close" })),
|
|
8
|
+
image && title && (h("div", { class: "infobox__image-container" },
|
|
9
|
+
h(Image, { classes: "infobox__image", image: image, alt: title, preload: {
|
|
10
|
+
width: 325,
|
|
11
|
+
height: 117,
|
|
12
|
+
} }))),
|
|
13
|
+
h("div", { class: "infobox__wrapper" },
|
|
14
|
+
title && h("h3", { class: "infobox__title" }, title),
|
|
15
|
+
tags && h("span", { class: "infobox__tags" }, tags === null || tags === void 0 ? void 0 : tags.join(', ')),
|
|
16
|
+
description && h("p", { class: "infobox__description" }, description),
|
|
17
|
+
link && (h(ButtonA, { target: openInTab ? '_blank' : '_self', url: link, label: "Bekijk het gebied" })))));
|
|
18
|
+
|
|
19
|
+
export { Infobox };
|
|
20
|
+
//# sourceMappingURL=infobox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infobox.js","sources":["../../../../src/molecules/infobox/infobox.tsx"],"sourcesContent":["import { h } from '@atomify/jsx';\nimport { MapInfobox } from '@bpd-library/types';\n\nimport { ButtonA } from '../../atoms/button';\nimport { Image } from '../../atoms/image';\n\ninterface InfoboxInterface extends MapInfobox {\n onClose: () => void;\n openInTab?: boolean;\n}\n\nexport const Infobox = ({\n title,\n image,\n tags,\n description,\n link,\n onClose,\n openInTab,\n}: InfoboxInterface) => (\n <div class=\"c-infobox\">\n <button class=\"infobox__close\" onClick={onClose}>\n <bpd-svg name=\"icons-close\" />\n </button>\n {image && title && (\n <div class=\"infobox__image-container\">\n <Image\n classes=\"infobox__image\"\n image={image}\n alt={title}\n preload={{\n width: 325,\n height: 117,\n }}\n />\n </div>\n )}\n <div class=\"infobox__wrapper\">\n {title && <h3 class=\"infobox__title\">{title}</h3>}\n {tags && <span class=\"infobox__tags\">{tags?.join(', ')}</span>}\n {description && <p class=\"infobox__description\">{description}</p>}\n {link && (\n <ButtonA\n target={openInTab ? '_blank' : '_self'}\n url={link}\n label=\"Bekijk het gebied\"\n />\n )}\n </div>\n </div>\n);\n"],"names":[],"mappings":";;;;MAWa,OAAO,GAAG,CAAC,EACpB,KAAK,EACL,KAAK,EACL,IAAI,EACJ,WAAW,EACX,IAAI,EACJ,OAAO,EACP,SAAS,GACM,MACf,WAAK,KAAK,EAAC,WAAW;IAClB,cAAQ,KAAK,EAAC,gBAAgB,EAAC,OAAO,EAAE,OAAO;QAC3C,eAAS,IAAI,EAAC,aAAa,GAAG,CACzB;IACR,KAAK,IAAI,KAAK,KACX,WAAK,KAAK,EAAC,0BAA0B;QACjC,EAAC,KAAK,IACF,OAAO,EAAC,gBAAgB,EACxB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,KAAK,EACV,OAAO,EAAE;gBACL,KAAK,EAAE,GAAG;gBACV,MAAM,EAAE,GAAG;aACd,GACH,CACA,CACT;IACD,WAAK,KAAK,EAAC,kBAAkB;QACxB,KAAK,IAAI,UAAI,KAAK,EAAC,gBAAgB,IAAE,KAAK,CAAM;QAChD,IAAI,IAAI,YAAM,KAAK,EAAC,eAAe,IAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC,IAAI,EAAS;QAC7D,WAAW,IAAI,SAAG,KAAK,EAAC,sBAAsB,IAAE,WAAW,CAAK;QAChE,IAAI,KACD,EAAC,OAAO,IACJ,MAAM,EAAE,SAAS,GAAG,QAAQ,GAAG,OAAO,EACtC,GAAG,EAAE,IAAI,EACT,KAAK,EAAC,mBAAmB,GAC3B,CACL,CACC,CACJ;;;;"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { defineElement, useProp, useElement, onDidLoad } from '@atomify/hooks';
|
|
2
|
+
import { h, Fragment } from '@atomify/jsx';
|
|
3
|
+
import { detectTouch, calculateMapDataBoundingBox, expandBoundingBox, calculateMapDataCenter, getCountryBoundingBox, functionIsTrue } from '@bpd-library/utilities';
|
|
4
|
+
import MapboxLanguage from '@mapbox/mapbox-gl-language';
|
|
5
|
+
import mapboxgl from 'mapbox-gl';
|
|
6
|
+
import { Button } from '../../atoms/button/button.js';
|
|
7
|
+
import { Infobox } from '../infobox/infobox.js';
|
|
8
|
+
import { setMapInstance, mapStore, clearHover } from './store/map/store.js';
|
|
9
|
+
import mapbox from './utilities/mapbox/mapbox.js';
|
|
10
|
+
|
|
11
|
+
const DEFAULT_OPTIONS = {
|
|
12
|
+
zoomButtons: true,
|
|
13
|
+
mobileToggle: false,
|
|
14
|
+
tooltipMode: 'hover',
|
|
15
|
+
openInTab: false,
|
|
16
|
+
autoOpenUrl: true,
|
|
17
|
+
language: window.__ENVIRONMENT_DETAILS__.language || 'nl',
|
|
18
|
+
searchCountryIsoCodes: ['nl', 'de'],
|
|
19
|
+
};
|
|
20
|
+
const CONTAINER_VISIBLE = 'map--is-visible';
|
|
21
|
+
const MOBILE_TOGGLE_CLASS = 'map--mobile-toggle';
|
|
22
|
+
const MAP_HOVERING_CLASS = 'map--hovering';
|
|
23
|
+
const POINTER_FOCUS_CLASS = 'map__pointer--focus';
|
|
24
|
+
const Map = () => {
|
|
25
|
+
let [options] = useProp('options', {});
|
|
26
|
+
const [theme] = useProp('theme');
|
|
27
|
+
const container = useElement('[js-hook-map-container]');
|
|
28
|
+
const infoboxWrapper = useElement('[js-hook-infobox-wrapper]');
|
|
29
|
+
const element = useElement('[js-hook-map]');
|
|
30
|
+
let map;
|
|
31
|
+
let mapboxHelpers;
|
|
32
|
+
onDidLoad(async () => {
|
|
33
|
+
if (options.mobileToggle)
|
|
34
|
+
element.current.classList.add(MOBILE_TOGGLE_CLASS);
|
|
35
|
+
options = Object.assign(Object.assign({}, DEFAULT_OPTIONS), options);
|
|
36
|
+
map = createMapboxInstance();
|
|
37
|
+
mapboxHelpers = mapbox(map, options, theme);
|
|
38
|
+
setMapInstance(map);
|
|
39
|
+
await setupMapbox();
|
|
40
|
+
subscribe();
|
|
41
|
+
if (options.search)
|
|
42
|
+
options.search.forEach((e) => mapboxHelpers.search(e));
|
|
43
|
+
});
|
|
44
|
+
function subscribe() {
|
|
45
|
+
const { filter, data } = mapStore.getState();
|
|
46
|
+
const { addData } = mapboxHelpers;
|
|
47
|
+
addData(filter ? filter : data);
|
|
48
|
+
mapStore.subscribe(({ data }) => addData(data), ['data']);
|
|
49
|
+
mapStore.subscribe(handleHover, ['hover']);
|
|
50
|
+
mapStore.subscribe(handleClick, ['click']);
|
|
51
|
+
mapStore.subscribe(handleFocus, ['focus']);
|
|
52
|
+
mapStore.subscribe(({ filter, data }) => addData(filter ? filter : data), ['filter']);
|
|
53
|
+
mapStore.subscribe(({ layerRasterSettings }) => layerRasterSettings && mapboxHelpers.raster(layerRasterSettings), ['layerRasterSettings']);
|
|
54
|
+
}
|
|
55
|
+
function handleHover({ hover }) {
|
|
56
|
+
const { current, previous } = hover;
|
|
57
|
+
const canvasStyle = map.getCanvas().style;
|
|
58
|
+
const { setFeatureState, addTooltip, removeTooltip } = mapboxHelpers;
|
|
59
|
+
if (options.tooltipMode === 'hover') {
|
|
60
|
+
if ((current === null || current === void 0 ? void 0 : current.tooltip) && !detectTouch.touch)
|
|
61
|
+
addTooltip(current.coordinates, current);
|
|
62
|
+
if (!current && !detectTouch.touch)
|
|
63
|
+
removeTooltip();
|
|
64
|
+
}
|
|
65
|
+
if (hasHoverTheme()) {
|
|
66
|
+
if (current)
|
|
67
|
+
setFeatureState(current.variant, current.id, 'hover', true);
|
|
68
|
+
if (previous)
|
|
69
|
+
setFeatureState(previous.variant, previous.id, 'hover', false);
|
|
70
|
+
}
|
|
71
|
+
canvasStyle.cursor = current ? 'pointer' : '';
|
|
72
|
+
}
|
|
73
|
+
function handleClick({ click }) {
|
|
74
|
+
if (!click)
|
|
75
|
+
return;
|
|
76
|
+
const { addTooltip } = mapboxHelpers;
|
|
77
|
+
const { infobox, coordinates, tooltip, url } = click;
|
|
78
|
+
clearHover();
|
|
79
|
+
if (options.tooltipMode === 'click' && tooltip) {
|
|
80
|
+
addTooltip(coordinates, click);
|
|
81
|
+
}
|
|
82
|
+
if (options.tooltipMode === 'hover') {
|
|
83
|
+
if (url && !detectTouch.touch && options.autoOpenUrl) {
|
|
84
|
+
window.open(url, options.openInTab ? '_blank' : '_self');
|
|
85
|
+
}
|
|
86
|
+
else if ((url && tooltip) || (detectTouch.touch && !url && tooltip)) {
|
|
87
|
+
addTooltip(coordinates, click);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (infobox) {
|
|
91
|
+
showInfobox(infobox);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
clearInfobox();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function handleFocus({ focus }) {
|
|
98
|
+
const { current, previous, options } = focus;
|
|
99
|
+
const { setFeatureState, center, addTooltip, removeTooltip } = mapboxHelpers;
|
|
100
|
+
if (previous) {
|
|
101
|
+
previous.forEach(({ id, variant }) => {
|
|
102
|
+
if (hasHoverTheme())
|
|
103
|
+
setFeatureState(variant, id, 'focus', false);
|
|
104
|
+
pointerFocusToggle(id, 'remove');
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (current) {
|
|
108
|
+
current.forEach((item) => {
|
|
109
|
+
const { variant, id, coordinates, tooltip } = item;
|
|
110
|
+
function handleTooltip() {
|
|
111
|
+
const showTooltip = (options === null || options === void 0 ? void 0 : options.toggleTooltip) && tooltip;
|
|
112
|
+
if (theme.polygon || pointerExists(id)) {
|
|
113
|
+
if (showTooltip)
|
|
114
|
+
addTooltip(coordinates, item);
|
|
115
|
+
pointerFocusToggle(id, 'add');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (theme.polygon) {
|
|
119
|
+
if (hasHoverTheme())
|
|
120
|
+
setFeatureState(variant, id, 'focus', true);
|
|
121
|
+
}
|
|
122
|
+
if (pointerExists(id)) {
|
|
123
|
+
handleTooltip();
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
map.once('idle', handleTooltip);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
if (options === null || options === void 0 ? void 0 : options.zoom) {
|
|
130
|
+
let bounds = calculateMapDataBoundingBox(current);
|
|
131
|
+
bounds = expandBoundingBox(bounds, 0.05);
|
|
132
|
+
map.fitBounds(bounds);
|
|
133
|
+
}
|
|
134
|
+
else if (!(options === null || options === void 0 ? void 0 : options.static)) {
|
|
135
|
+
center([[calculateMapDataCenter(current)]]);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
removeTooltip();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function pointerFocusToggle(id, action) {
|
|
143
|
+
const pointer = getPointerElementById(id);
|
|
144
|
+
if (pointer) {
|
|
145
|
+
pointer.classList[action](POINTER_FOCUS_CLASS);
|
|
146
|
+
element.current.classList[action](MAP_HOVERING_CLASS);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function showInfobox(infobox) {
|
|
150
|
+
clearInfobox();
|
|
151
|
+
infoboxWrapper.current.appendChild(h(Infobox, Object.assign({}, infobox, { onClose: clearInfobox, openInTab: options.openInTab })));
|
|
152
|
+
}
|
|
153
|
+
function clearInfobox() {
|
|
154
|
+
infoboxWrapper.current.innerHTML = '';
|
|
155
|
+
}
|
|
156
|
+
function toggleMap() {
|
|
157
|
+
element.current.classList.toggle(CONTAINER_VISIBLE);
|
|
158
|
+
map.resize();
|
|
159
|
+
}
|
|
160
|
+
function hasHoverTheme() {
|
|
161
|
+
return theme.polygon && theme.polygon.settings[0].hover;
|
|
162
|
+
}
|
|
163
|
+
function createMapboxInstance() {
|
|
164
|
+
mapboxgl.accessToken = window.__ENVIRONMENT_DETAILS__.mapbox.accessToken;
|
|
165
|
+
const mapboxOptions = {
|
|
166
|
+
container: container.current,
|
|
167
|
+
style: `mapbox://styles/${window.__ENVIRONMENT_DETAILS__.mapbox.style}`,
|
|
168
|
+
minZoom: 4,
|
|
169
|
+
maxZoom: 30,
|
|
170
|
+
dragPan: true,
|
|
171
|
+
scrollZoom: false,
|
|
172
|
+
};
|
|
173
|
+
if (options.center)
|
|
174
|
+
mapboxOptions.center = options.center;
|
|
175
|
+
if (options.zoom)
|
|
176
|
+
mapboxOptions.zoom = options.zoom;
|
|
177
|
+
if (options.boundingBox)
|
|
178
|
+
mapboxOptions.bounds = options.boundingBox;
|
|
179
|
+
if (!options.zoom && !options.center && !options.boundingBox) {
|
|
180
|
+
mapboxOptions.bounds = getCountryBoundingBox(['nl']);
|
|
181
|
+
}
|
|
182
|
+
return new mapboxgl.Map(mapboxOptions);
|
|
183
|
+
}
|
|
184
|
+
function getMapboxLanguageString() {
|
|
185
|
+
let language;
|
|
186
|
+
if (options.language) {
|
|
187
|
+
language = options.language.substr(0, 2);
|
|
188
|
+
}
|
|
189
|
+
language = !language || language === 'nl' ? 'mul' : language;
|
|
190
|
+
return language;
|
|
191
|
+
}
|
|
192
|
+
async function setupMapbox() {
|
|
193
|
+
const { raster, geojson, layer, interaction, setupPointers } = mapboxHelpers;
|
|
194
|
+
await functionIsTrue(() => map.isStyleLoaded());
|
|
195
|
+
const languageControl = new MapboxLanguage({
|
|
196
|
+
defaultLanguage: getMapboxLanguageString(),
|
|
197
|
+
});
|
|
198
|
+
map.addControl(languageControl);
|
|
199
|
+
const optionsLayerRaster = options.layerRaster
|
|
200
|
+
? { layerRaster: options.layerRaster }
|
|
201
|
+
: undefined;
|
|
202
|
+
const storeLayerRaster = mapStore.getState().layerRasterSettings;
|
|
203
|
+
if (optionsLayerRaster) {
|
|
204
|
+
raster(optionsLayerRaster);
|
|
205
|
+
}
|
|
206
|
+
else if (storeLayerRaster) {
|
|
207
|
+
raster(storeLayerRaster);
|
|
208
|
+
}
|
|
209
|
+
if (theme.polygon) {
|
|
210
|
+
theme.polygon.settings.forEach((setting) => {
|
|
211
|
+
geojson(setting);
|
|
212
|
+
layer(setting);
|
|
213
|
+
interaction(setting);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
if (theme.pointer) {
|
|
217
|
+
setupPointers(element.current);
|
|
218
|
+
}
|
|
219
|
+
map.resize();
|
|
220
|
+
}
|
|
221
|
+
function getPointerElementById(id) {
|
|
222
|
+
return element.current.querySelector(`#pointer-${id}`);
|
|
223
|
+
}
|
|
224
|
+
function pointerExists(id) {
|
|
225
|
+
return !!getPointerElementById(id);
|
|
226
|
+
}
|
|
227
|
+
return (h(Fragment, null,
|
|
228
|
+
h("div", { class: "c-map", "js-hook-map": true },
|
|
229
|
+
h("div", { className: "map__container", "js-hook-map-container": true },
|
|
230
|
+
options.zoomButtons && (h("div", { class: "map__navigation" },
|
|
231
|
+
h("button", { class: "map__button", onClick: () => map.zoomIn() },
|
|
232
|
+
h("bpd-svg", { name: "icons-plus" })),
|
|
233
|
+
h("button", { class: "map__button", onClick: () => map.zoomOut() },
|
|
234
|
+
h("span", { class: "map__minus" })))),
|
|
235
|
+
options.mobileToggle && (h("button", { type: "button", class: "map__close", onClick: toggleMap },
|
|
236
|
+
h("bpd-svg", { name: "icons-close" }))),
|
|
237
|
+
h("div", { class: "map__infobox-wrapper", "js-hook-infobox-wrapper": true }))),
|
|
238
|
+
options.mobileToggle && (h(Fragment, null,
|
|
239
|
+
h(Button, { variant: "bg", label: options.mobileToggleLabel || 'Toon kaart', classes: "map__open", onClick: toggleMap })))));
|
|
240
|
+
};
|
|
241
|
+
Map.props = {
|
|
242
|
+
options: {
|
|
243
|
+
type: Object,
|
|
244
|
+
},
|
|
245
|
+
theme: {
|
|
246
|
+
type: Object,
|
|
247
|
+
required: true,
|
|
248
|
+
},
|
|
249
|
+
zoomButtons: {
|
|
250
|
+
type: Boolean,
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
defineElement('bpd-map', Map);
|
|
254
|
+
|
|
255
|
+
export { Map };
|
|
256
|
+
//# sourceMappingURL=map.js.map
|