@m3ui-vue/m3ui-vue 1.0.2 → 1.0.3
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/API.md +599 -9
- package/dist/MMenuItem-DFyXflk9.js +707 -0
- package/dist/MMenuItem-DFyXflk9.js.map +1 -0
- package/dist/MSlider-CdNIH7jc.js +1376 -0
- package/dist/MSlider-CdNIH7jc.js.map +1 -0
- package/dist/MTextField-B4X92vH_.js +671 -0
- package/dist/MTextField-B4X92vH_.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MIconButton.vue.d.ts +1 -1
- package/dist/components/MMap.vue.d.ts +74 -0
- package/dist/components/MMapBaseLayers.vue.d.ts +15 -0
- package/dist/components/MMapControl.vue.d.ts +23 -0
- package/dist/components/MMapFeatureInfo.vue.d.ts +25 -0
- package/dist/components/MMapFilter.vue.d.ts +19 -0
- package/dist/components/MMapGeoJson.vue.d.ts +34 -0
- package/dist/components/MMapHover.vue.d.ts +17 -0
- package/dist/components/MMapIdentify.vue.d.ts +37 -0
- package/dist/components/MMapLayers.vue.d.ts +31 -0
- package/dist/components/MMapMarker.vue.d.ts +42 -0
- package/dist/components/MMapMeasure.vue.d.ts +43 -0
- package/dist/components/MMapPopup.vue.d.ts +43 -0
- package/dist/components/MMapSearch.vue.d.ts +28 -0
- package/dist/components/_MMapLayerItem.vue.d.ts +25 -0
- package/dist/composables/_mapGeometry.d.ts +13 -0
- package/dist/composables/_ssrState.d.ts +30 -0
- package/dist/composables/_storageKeys.d.ts +3 -0
- package/dist/composables/_useThemeTokens.d.ts +7 -0
- package/dist/composables/mapAdapters.d.ts +111 -0
- package/dist/composables/mapSearch.d.ts +31 -0
- package/dist/composables/themeInitScript.d.ts +4 -3
- package/dist/composables/useColorPalette.d.ts +173 -7
- package/dist/composables/useLocale.d.ts +30 -0
- package/dist/composables/useMap.d.ts +47 -0
- package/dist/composables/useMapFilter.d.ts +10 -0
- package/dist/composables/useMapLayers.d.ts +30 -0
- package/dist/composables/useTheme.d.ts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/locales/index.js +217 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +6709 -7976
- package/dist/m3ui.js.map +1 -1
- package/dist/map.d.ts +24 -0
- package/dist/map.js +1931 -0
- package/dist/map.js.map +1 -0
- package/dist/plugin.d.ts +18 -2
- package/dist/rich-text-editor.js +27 -26
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/{useLocale-CuvWRZ1h.js → useLocale-b5-hzsL3.js} +32 -2
- package/dist/useLocale-b5-hzsL3.js.map +1 -0
- package/package.json +11 -2
- package/src/__tests__/MFab.test.ts +52 -6
- package/src/__tests__/MMap.test.ts +292 -0
- package/src/__tests__/MMapLayers.test.ts +257 -0
- package/src/__tests__/MMapTools.test.ts +233 -0
- package/src/__tests__/_fakeMaplibre.ts +158 -0
- package/src/__tests__/hydration.test.ts +33 -0
- package/src/__tests__/ssr.test.ts +63 -1
- package/src/__tests__/ssrState.test.ts +155 -0
- package/src/__tests__/themeInitScript.test.ts +18 -0
- package/src/components/MFab.vue +29 -7
- package/src/components/MIconButton.vue +1 -1
- package/src/components/MLightbox.vue +6 -2
- package/src/components/MMap.vue +522 -0
- package/src/components/MMapBaseLayers.vue +67 -0
- package/src/components/MMapControl.vue +61 -0
- package/src/components/MMapFeatureInfo.vue +41 -0
- package/src/components/MMapFilter.vue +80 -0
- package/src/components/MMapGeoJson.vue +136 -0
- package/src/components/MMapHover.vue +131 -0
- package/src/components/MMapIdentify.vue +103 -0
- package/src/components/MMapLayers.vue +111 -0
- package/src/components/MMapMarker.vue +102 -0
- package/src/components/MMapMeasure.vue +452 -0
- package/src/components/MMapPopup.vue +99 -0
- package/src/components/MMapSearch.vue +162 -0
- package/src/components/_MMapLayerItem.vue +77 -0
- package/src/composables/_mapGeometry.ts +75 -0
- package/src/composables/_ssrState.ts +80 -0
- package/src/composables/_storageKeys.ts +6 -0
- package/src/composables/_useThemeTokens.ts +42 -0
- package/src/composables/mapAdapters.ts +208 -0
- package/src/composables/mapSearch.ts +56 -0
- package/src/composables/themeInitScript.ts +6 -4
- package/src/composables/useColorPalette.ts +23 -9
- package/src/composables/useLocale.ts +62 -0
- package/src/composables/useMap.ts +98 -0
- package/src/composables/useMapFilter.ts +45 -0
- package/src/composables/useMapLayers.ts +124 -0
- package/src/composables/useTheme.ts +8 -3
- package/src/composables/useWindowSizeClass.ts +14 -5
- package/src/index.ts +2 -1
- package/src/locales/de.ts +31 -1
- package/src/locales/es.ts +31 -1
- package/src/locales/fr.ts +31 -1
- package/src/locales/ja.ts +31 -1
- package/src/locales/ko.ts +31 -1
- package/src/locales/pt.ts +31 -1
- package/src/locales/zh.ts +31 -1
- package/src/map.ts +32 -0
- package/src/plugin.ts +54 -3
- package/dist/MTextField-BPbFeI9M.js +0 -1368
- package/dist/MTextField-BPbFeI9M.js.map +0 -1
- package/dist/useLocale-CuvWRZ1h.js.map +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type * as Maplibre from 'maplibre-gl';
|
|
2
|
+
/** How to show one property of a feature. */
|
|
3
|
+
export interface MapFieldFormat {
|
|
4
|
+
/** The label (the key, capitalized, by default) */
|
|
5
|
+
label?: string;
|
|
6
|
+
/** Text before the value */
|
|
7
|
+
prefix?: string;
|
|
8
|
+
/** Text after the value */
|
|
9
|
+
suffix?: string;
|
|
10
|
+
/** A number mask: its decimals set the fraction digits (`#.00` → 2) and a comma turns on grouping (`#,###`) */
|
|
11
|
+
mask?: string;
|
|
12
|
+
/** Leave it out */
|
|
13
|
+
hidden?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** One layer of the style, as the map's UI components see it. */
|
|
16
|
+
export interface MapLayerInfo {
|
|
17
|
+
/** The style layer's id */
|
|
18
|
+
id: string;
|
|
19
|
+
/** Its name in the UI */
|
|
20
|
+
title: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
/** The `name` of its group in `MapLayerModel.groups` */
|
|
23
|
+
group?: string;
|
|
24
|
+
/** Shown in `MMapLayers` */
|
|
25
|
+
listed: boolean;
|
|
26
|
+
/** A base layer: `MMapBaseLayers` shows one of them at a time, with this thumbnail */
|
|
27
|
+
base?: {
|
|
28
|
+
image?: string;
|
|
29
|
+
};
|
|
30
|
+
/** Layer ids shown, hidden and faded along with it */
|
|
31
|
+
children: string[];
|
|
32
|
+
/** Listed by `MMapIdentify` on click: every property, formatted by `format`, minus `exclude` */
|
|
33
|
+
identify: false | {
|
|
34
|
+
format: Record<string, MapFieldFormat>;
|
|
35
|
+
exclude: string[];
|
|
36
|
+
};
|
|
37
|
+
/** Shown by `MMapHover` under the pointer: these properties, in order */
|
|
38
|
+
hover: false | {
|
|
39
|
+
fields: (MapFieldFormat & {
|
|
40
|
+
key: string;
|
|
41
|
+
})[];
|
|
42
|
+
};
|
|
43
|
+
/** A legend image URL (an SVG, typically) */
|
|
44
|
+
legend?: string;
|
|
45
|
+
/** A download URL for its data */
|
|
46
|
+
download?: string;
|
|
47
|
+
}
|
|
48
|
+
/** The style as the map's UI components see it: layers with names, groups, base layers, what to identify. */
|
|
49
|
+
export interface MapLayerModel {
|
|
50
|
+
/** The style's name */
|
|
51
|
+
title?: string;
|
|
52
|
+
/** Groups, in order */
|
|
53
|
+
groups: {
|
|
54
|
+
name: string;
|
|
55
|
+
title: string;
|
|
56
|
+
}[];
|
|
57
|
+
/** Layers, in the style's order (bottom to top) */
|
|
58
|
+
layers: MapLayerInfo[];
|
|
59
|
+
}
|
|
60
|
+
/** What an adapter gets besides the style. */
|
|
61
|
+
export interface MapAdapterContext {
|
|
62
|
+
/** The style's URL, when `MMap`'s `mapStyle` is one */
|
|
63
|
+
styleUrl?: string;
|
|
64
|
+
}
|
|
65
|
+
/** Reads a style's conventions (usually its `metadata`) into the model the map's UI components use. */
|
|
66
|
+
export type MapAdapter = (style: Maplibre.StyleSpecification, context: MapAdapterContext) => MapLayerModel;
|
|
67
|
+
/**
|
|
68
|
+
* Any style: every layer but the background is listed under its id (or `metadata.title`), vector layers identify all
|
|
69
|
+
* their properties, and nothing is a base layer or shows on hover.
|
|
70
|
+
*/
|
|
71
|
+
export declare const genericAdapter: MapAdapter;
|
|
72
|
+
export interface OrvianAdapterOptions {
|
|
73
|
+
/**
|
|
74
|
+
* A layer's legend image. By default, for a style served by mvt-rs (`…/services/styles/<style>`), its legend service
|
|
75
|
+
* (`…/services/legends/<style>?layer_id=<id>`), unless the layer's `metadata.legend.show` is false;
|
|
76
|
+
* `metadata.legend.wmslegend` overrides it
|
|
77
|
+
*/
|
|
78
|
+
legend?: (layer: Maplibre.LayerSpecification, styleUrl?: string) => string | undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The Orvian viewers' conventions in the style's `metadata`. On each layer: `alias`, `description`, `group`,
|
|
82
|
+
* `show_in_layerlist` (false hides it from the list), `isbaselayer` with `image` (raster base layers), `childs` (layer
|
|
83
|
+
* ids toggled with it), `identify` (true lists its properties on click), `fields` (per property: `alias`, `prefix`,
|
|
84
|
+
* `suffix`, `mask`, `show: false`; plus `exclude`, a list of properties to leave out), `hover` (`enable` and `fields`,
|
|
85
|
+
* a list of `{ <property>: { alias, prefix, suffix, mask } }`), `legend` (`show`, `wmslegend`) and `download`. On the
|
|
86
|
+
* style: `groups` (`{ name, alias }`, in order).
|
|
87
|
+
*/
|
|
88
|
+
export declare function orvianAdapter(options?: OrvianAdapterOptions): MapAdapter;
|
|
89
|
+
/** A property's label: its format's, or the key with a capital first letter. */
|
|
90
|
+
export declare function fieldLabel(key: string, format?: MapFieldFormat): string;
|
|
91
|
+
/**
|
|
92
|
+
* A property's value as text: numbers through `mask` (in the page's language, `<html lang>`), then `prefix` and
|
|
93
|
+
* `suffix`. Empty values give ''.
|
|
94
|
+
*/
|
|
95
|
+
export declare function formatFieldValue(raw: unknown, format?: MapFieldFormat): string;
|
|
96
|
+
/** What `MMapIdentify` found on one layer at a point. */
|
|
97
|
+
export interface MapIdentifyResult {
|
|
98
|
+
layer: MapLayerInfo;
|
|
99
|
+
feature: Maplibre.MapGeoJSONFeature;
|
|
100
|
+
/** Its properties as the layer's `identify` shows them, formatted */
|
|
101
|
+
fields: {
|
|
102
|
+
key: string;
|
|
103
|
+
label: string;
|
|
104
|
+
value: string;
|
|
105
|
+
}[];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The features of the model's identify layers at a point (topmost first), with their properties formatted: what
|
|
109
|
+
* `MMapIdentify` lists on click, for a UI of your own.
|
|
110
|
+
*/
|
|
111
|
+
export declare function identifyFeatures(map: Maplibre.Map, point: Maplibre.PointLike, model: MapLayerModel | undefined): MapIdentifyResult[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** A place found by a `MapSearchProvider`. */
|
|
2
|
+
export interface MapSearchResult {
|
|
3
|
+
/** What to show */
|
|
4
|
+
label: string;
|
|
5
|
+
/** Where it is */
|
|
6
|
+
lngLat: [number, number];
|
|
7
|
+
/** Its extent, `[west, south, east, north]`: the map fits it instead of zooming to the point */
|
|
8
|
+
bbox?: [number, number, number, number];
|
|
9
|
+
/** Its kind (`city`, `road`, `park`, `restaurant`…), for the icon */
|
|
10
|
+
type?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Finds places for `MMapSearch`: the text in, results out. `signal` aborts a search the user replaced. */
|
|
13
|
+
export type MapSearchProvider = (query: string, signal: AbortSignal) => Promise<MapSearchResult[]>;
|
|
14
|
+
export interface NominatimOptions {
|
|
15
|
+
/** The Nominatim server (`https://nominatim.openstreetmap.org` by default; mind its usage policy, or run your own) */
|
|
16
|
+
url?: string;
|
|
17
|
+
/** How many results (6) */
|
|
18
|
+
limit?: number;
|
|
19
|
+
/** The results' language (`es`, `en`…); by default the page's (`<html lang>`) */
|
|
20
|
+
language?: string;
|
|
21
|
+
/** Only these countries (ISO codes: `['ar']`) */
|
|
22
|
+
countryCodes?: string[];
|
|
23
|
+
/** Prefer (or with `bounded`, only) this area: `[west, south, east, north]` */
|
|
24
|
+
viewbox?: [number, number, number, number];
|
|
25
|
+
bounded?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* OpenStreetMap's Nominatim geocoder. Its public server allows one search per second and no search-as-you-type:
|
|
29
|
+
* `MMapSearch` searches on Enter.
|
|
30
|
+
*/
|
|
31
|
+
export declare function nominatimProvider(options?: NominatimOptions): MapSearchProvider;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type ContrastLevel } from './useColorPalette';
|
|
1
|
+
import { type ContrastLevel, type PaletteId } from './useColorPalette';
|
|
2
2
|
export interface ThemeInitOptions {
|
|
3
3
|
/** `createM3UI`'s `palette`: the first-visit default, or forced with `persistPalette: false`. */
|
|
4
|
-
palette?: string;
|
|
4
|
+
palette?: PaletteId | (string & {});
|
|
5
5
|
/** `createM3UI`'s `contrast`, with the same rules as `palette`. */
|
|
6
6
|
contrast?: ContrastLevel;
|
|
7
7
|
/** `createM3UI`'s `persistPalette`. */
|
|
@@ -11,7 +11,8 @@ export interface ThemeInitOptions {
|
|
|
11
11
|
* A script to inline in `<head>` of a server-rendered page (Nuxt, Vite SSR), so dark mode, the palette and the
|
|
12
12
|
* contrast level are on `<html>` before the first paint instead of when the app's JS loads. It does what
|
|
13
13
|
* `useTheme` and `useColorPalette` do when they load in the browser (the stored choice, or the given
|
|
14
|
-
* `createM3UI` defaults
|
|
14
|
+
* `createM3UI` defaults; a choice only in a cookie, from `createM3UI({ cookies })`, counts too), so pass it the same
|
|
15
|
+
* options as the plugin. A `seed` default can't be generated this
|
|
15
16
|
* early: its first visit still shows the baseline until the app loads (later visits use the cached CSS).
|
|
16
17
|
*
|
|
17
18
|
* ```ts
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
1
2
|
import { type SeedOptions } from './dynamicColor';
|
|
3
|
+
import { STYLE_ID } from './_storageKeys';
|
|
2
4
|
export interface Palette {
|
|
3
5
|
id: string;
|
|
4
6
|
label: string;
|
|
@@ -8,6 +10,170 @@ export interface Palette {
|
|
|
8
10
|
*/
|
|
9
11
|
seed: string;
|
|
10
12
|
}
|
|
13
|
+
declare const builtInPalettes: readonly [{
|
|
14
|
+
readonly id: "purple";
|
|
15
|
+
readonly label: "Purple";
|
|
16
|
+
readonly seed: "#6750A4";
|
|
17
|
+
}, {
|
|
18
|
+
readonly id: "indigo";
|
|
19
|
+
readonly label: "Indigo";
|
|
20
|
+
readonly seed: "#4355B9";
|
|
21
|
+
}, {
|
|
22
|
+
readonly id: "navy";
|
|
23
|
+
readonly label: "Navy";
|
|
24
|
+
readonly seed: "#354BA0";
|
|
25
|
+
}, {
|
|
26
|
+
readonly id: "blue";
|
|
27
|
+
readonly label: "Blue";
|
|
28
|
+
readonly seed: "#005AC1";
|
|
29
|
+
}, {
|
|
30
|
+
readonly id: "cyan";
|
|
31
|
+
readonly label: "Cyan";
|
|
32
|
+
readonly seed: "#006874";
|
|
33
|
+
}, {
|
|
34
|
+
readonly id: "teal";
|
|
35
|
+
readonly label: "Teal";
|
|
36
|
+
readonly seed: "#006B5F";
|
|
37
|
+
}, {
|
|
38
|
+
readonly id: "green";
|
|
39
|
+
readonly label: "Green";
|
|
40
|
+
readonly seed: "#386A20";
|
|
41
|
+
}, {
|
|
42
|
+
readonly id: "lime";
|
|
43
|
+
readonly label: "Lime";
|
|
44
|
+
readonly seed: "#4C6706";
|
|
45
|
+
}, {
|
|
46
|
+
readonly id: "olive";
|
|
47
|
+
readonly label: "Olive";
|
|
48
|
+
readonly seed: "#636118";
|
|
49
|
+
}, {
|
|
50
|
+
readonly id: "amber";
|
|
51
|
+
readonly label: "Amber";
|
|
52
|
+
readonly seed: "#785900";
|
|
53
|
+
}, {
|
|
54
|
+
readonly id: "sand";
|
|
55
|
+
readonly label: "Sand";
|
|
56
|
+
readonly seed: "#715C2E";
|
|
57
|
+
}, {
|
|
58
|
+
readonly id: "orange";
|
|
59
|
+
readonly label: "Orange";
|
|
60
|
+
readonly seed: "#8B5000";
|
|
61
|
+
}, {
|
|
62
|
+
readonly id: "deep-orange";
|
|
63
|
+
readonly label: "Deep Orange";
|
|
64
|
+
readonly seed: "#96480A";
|
|
65
|
+
}, {
|
|
66
|
+
readonly id: "brown";
|
|
67
|
+
readonly label: "Brown";
|
|
68
|
+
readonly seed: "#6E4C32";
|
|
69
|
+
}, {
|
|
70
|
+
readonly id: "red";
|
|
71
|
+
readonly label: "Red";
|
|
72
|
+
readonly seed: "#B82000";
|
|
73
|
+
}, {
|
|
74
|
+
readonly id: "coral";
|
|
75
|
+
readonly label: "Coral";
|
|
76
|
+
readonly seed: "#A03530";
|
|
77
|
+
}, {
|
|
78
|
+
readonly id: "crimson";
|
|
79
|
+
readonly label: "Crimson";
|
|
80
|
+
readonly seed: "#9C4068";
|
|
81
|
+
}, {
|
|
82
|
+
readonly id: "pink";
|
|
83
|
+
readonly label: "Pink";
|
|
84
|
+
readonly seed: "#9C4057";
|
|
85
|
+
}, {
|
|
86
|
+
readonly id: "violet";
|
|
87
|
+
readonly label: "Violet";
|
|
88
|
+
readonly seed: "#7C39A4";
|
|
89
|
+
}, {
|
|
90
|
+
readonly id: "slate";
|
|
91
|
+
readonly label: "Slate";
|
|
92
|
+
readonly seed: "#4A6269";
|
|
93
|
+
}, {
|
|
94
|
+
readonly id: "graphite";
|
|
95
|
+
readonly label: "Graphite";
|
|
96
|
+
readonly seed: "#5C5C5C";
|
|
97
|
+
}, {
|
|
98
|
+
readonly id: "charcoal";
|
|
99
|
+
readonly label: "Charcoal";
|
|
100
|
+
readonly seed: "#3C3C3C";
|
|
101
|
+
}, {
|
|
102
|
+
readonly id: "steel";
|
|
103
|
+
readonly label: "Steel";
|
|
104
|
+
readonly seed: "#5A6A72";
|
|
105
|
+
}, {
|
|
106
|
+
readonly id: "ash";
|
|
107
|
+
readonly label: "Ash";
|
|
108
|
+
readonly seed: "#6B6560";
|
|
109
|
+
}, {
|
|
110
|
+
readonly id: "iron";
|
|
111
|
+
readonly label: "Iron";
|
|
112
|
+
readonly seed: "#505864";
|
|
113
|
+
}, {
|
|
114
|
+
readonly id: "fog";
|
|
115
|
+
readonly label: "Fog";
|
|
116
|
+
readonly seed: "#625E6E";
|
|
117
|
+
}, {
|
|
118
|
+
readonly id: "pewter";
|
|
119
|
+
readonly label: "Pewter";
|
|
120
|
+
readonly seed: "#5A6360";
|
|
121
|
+
}, {
|
|
122
|
+
readonly id: "smoke";
|
|
123
|
+
readonly label: "Smoke";
|
|
124
|
+
readonly seed: "#4D5C66";
|
|
125
|
+
}, {
|
|
126
|
+
readonly id: "stone";
|
|
127
|
+
readonly label: "Stone";
|
|
128
|
+
readonly seed: "#68635A";
|
|
129
|
+
}, {
|
|
130
|
+
readonly id: "zinc";
|
|
131
|
+
readonly label: "Zinc";
|
|
132
|
+
readonly seed: "#585B5E";
|
|
133
|
+
}, {
|
|
134
|
+
readonly id: "monochrome";
|
|
135
|
+
readonly label: "Monochrome";
|
|
136
|
+
readonly seed: "#000000";
|
|
137
|
+
}, {
|
|
138
|
+
readonly id: "rust";
|
|
139
|
+
readonly label: "Rust";
|
|
140
|
+
readonly seed: "#9C441E";
|
|
141
|
+
}, {
|
|
142
|
+
readonly id: "gold";
|
|
143
|
+
readonly label: "Gold";
|
|
144
|
+
readonly seed: "#715C00";
|
|
145
|
+
}, {
|
|
146
|
+
readonly id: "emerald";
|
|
147
|
+
readonly label: "Emerald";
|
|
148
|
+
readonly seed: "#006D39";
|
|
149
|
+
}, {
|
|
150
|
+
readonly id: "turquoise";
|
|
151
|
+
readonly label: "Turquoise";
|
|
152
|
+
readonly seed: "#006A68";
|
|
153
|
+
}, {
|
|
154
|
+
readonly id: "cobalt";
|
|
155
|
+
readonly label: "Cobalt";
|
|
156
|
+
readonly seed: "#006684";
|
|
157
|
+
}, {
|
|
158
|
+
readonly id: "sapphire";
|
|
159
|
+
readonly label: "Sapphire";
|
|
160
|
+
readonly seed: "#006399";
|
|
161
|
+
}, {
|
|
162
|
+
readonly id: "amethyst";
|
|
163
|
+
readonly label: "Amethyst";
|
|
164
|
+
readonly seed: "#5953AC";
|
|
165
|
+
}, {
|
|
166
|
+
readonly id: "magenta";
|
|
167
|
+
readonly label: "Magenta";
|
|
168
|
+
readonly seed: "#8D3F92";
|
|
169
|
+
}, {
|
|
170
|
+
readonly id: "mauve";
|
|
171
|
+
readonly label: "Mauve";
|
|
172
|
+
readonly seed: "#914277";
|
|
173
|
+
}];
|
|
174
|
+
/** The id of a palette that ships with the library (`palettes.css`, plus the `purple` baseline). */
|
|
175
|
+
export type PaletteId = (typeof builtInPalettes)[number]['id'];
|
|
176
|
+
/** Every palette: the built-in ones, plus `createM3UI({ customPalettes })`. */
|
|
11
177
|
export declare const palettes: Palette[];
|
|
12
178
|
/** The palette id used while a seed color is active (`useColorPalette().setSeed()`). */
|
|
13
179
|
export declare const SEED_PALETTE = "seed";
|
|
@@ -22,12 +188,12 @@ export declare const CSS_KEY = "m3-palette-css";
|
|
|
22
188
|
* `@m3ui-vue/m3ui-vue/palettes-contrast` imported for medium and high; seed palettes are regenerated.
|
|
23
189
|
*/
|
|
24
190
|
export type ContrastLevel = 'standard' | 'medium' | 'high' | 'system';
|
|
25
|
-
export
|
|
191
|
+
export { STYLE_ID };
|
|
26
192
|
export declare function useColorPalette(): {
|
|
27
|
-
palette:
|
|
193
|
+
palette: Ref<string, string>;
|
|
28
194
|
palettes: Palette[];
|
|
29
|
-
set: (id: string) => void;
|
|
30
|
-
seed: Readonly<
|
|
195
|
+
set: (id: PaletteId | (string & {})) => void;
|
|
196
|
+
seed: Readonly<Ref<{
|
|
31
197
|
readonly seed: string;
|
|
32
198
|
readonly variant?: import("./dynamicColor").SchemeVariant | undefined;
|
|
33
199
|
readonly contrast?: number | undefined;
|
|
@@ -37,10 +203,10 @@ export declare function useColorPalette(): {
|
|
|
37
203
|
readonly contrast?: number | undefined;
|
|
38
204
|
} | null>>;
|
|
39
205
|
setSeed: (seed: string, options?: SeedOptions) => Promise<void>;
|
|
40
|
-
contrast: Readonly<
|
|
41
|
-
activeContrast:
|
|
206
|
+
contrast: Readonly<Ref<ContrastLevel>>;
|
|
207
|
+
activeContrast: Ref<"medium" | "standard" | "high", "medium" | "standard" | "high">;
|
|
42
208
|
setContrast: (level: ContrastLevel) => void;
|
|
43
|
-
persistPalette:
|
|
209
|
+
persistPalette: Ref<boolean, boolean>;
|
|
44
210
|
setPersistPalette: (enabled: boolean) => void;
|
|
45
211
|
};
|
|
46
212
|
/**
|
|
@@ -146,6 +146,36 @@ export interface M3Locale {
|
|
|
146
146
|
nextPage: string;
|
|
147
147
|
carousel: string;
|
|
148
148
|
carouselItem: string;
|
|
149
|
+
mapTitle: string;
|
|
150
|
+
mapMarker: string;
|
|
151
|
+
mapZoomIn: string;
|
|
152
|
+
mapZoomOut: string;
|
|
153
|
+
mapResetBearing: string;
|
|
154
|
+
mapFindMyLocation: string;
|
|
155
|
+
mapLocationNotAvailable: string;
|
|
156
|
+
mapEnterFullscreen: string;
|
|
157
|
+
mapExitFullscreen: string;
|
|
158
|
+
mapToggleAttribution: string;
|
|
159
|
+
mapFeedback: string;
|
|
160
|
+
mapCtrlScroll: string;
|
|
161
|
+
mapCmdScroll: string;
|
|
162
|
+
mapTwoFingers: string;
|
|
163
|
+
mapLayers: string;
|
|
164
|
+
mapSearchLayers: string;
|
|
165
|
+
mapNoLayers: string;
|
|
166
|
+
mapShowLayer: string;
|
|
167
|
+
mapHideLayer: string;
|
|
168
|
+
mapOpacity: string;
|
|
169
|
+
mapDownload: string;
|
|
170
|
+
mapNoBaseLayer: string;
|
|
171
|
+
mapHoverInfo: string;
|
|
172
|
+
mapNoValue: string;
|
|
173
|
+
mapMeasureDistance: string;
|
|
174
|
+
mapMeasureArea: string;
|
|
175
|
+
mapClearMeasurements: string;
|
|
176
|
+
mapDeleteMeasurement: string;
|
|
177
|
+
mapTotal: string;
|
|
178
|
+
mapSearchPlaces: string;
|
|
149
179
|
}
|
|
150
180
|
export declare const defaultLocale: M3Locale;
|
|
151
181
|
export declare const M3_LOCALE_KEY: InjectionKey<MaybeRef<Partial<M3Locale>>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type ComputedRef, type InjectionKey, type Ref, type ShallowRef } from 'vue';
|
|
2
|
+
import type * as Maplibre from 'maplibre-gl';
|
|
3
|
+
import type { MapLayerModel } from './mapAdapters';
|
|
4
|
+
import type { MapLayerState } from './useMapLayers';
|
|
5
|
+
/** The `maplibre-gl` module (its classes: `Map`, `Marker`, `Popup`…) */
|
|
6
|
+
export type MaplibreModule = typeof import('maplibre-gl');
|
|
7
|
+
/** What `MMap` provides to everything inside it. */
|
|
8
|
+
export interface MapContext {
|
|
9
|
+
/** The MapLibre map, once created (never on the server) */
|
|
10
|
+
map: ShallowRef<Maplibre.Map | undefined>;
|
|
11
|
+
/** The `maplibre-gl` module, loaded with the map (so nothing imports it on the server) */
|
|
12
|
+
maplibre: ShallowRef<MaplibreModule | undefined>;
|
|
13
|
+
/** Bumped on every `style.load`: sources and layers added by components are re-added after a style change */
|
|
14
|
+
styleVersion: Ref<number>;
|
|
15
|
+
/** The style as `MMap`'s `adapter` reads it (undefined without one) */
|
|
16
|
+
model: ShallowRef<MapLayerModel | undefined>;
|
|
17
|
+
/** Visibility and opacity of the model's layers */
|
|
18
|
+
layerState: MapLayerState;
|
|
19
|
+
/**
|
|
20
|
+
* The tool that owns the map's clicks right now (`'measure'` while measuring), or null: `MMapIdentify` stays quiet
|
|
21
|
+
* meanwhile. Set it from tools of your own the same way
|
|
22
|
+
*/
|
|
23
|
+
activeTool: Ref<string | null>;
|
|
24
|
+
}
|
|
25
|
+
export declare const MAP_KEY: InjectionKey<MapContext>;
|
|
26
|
+
type MapEventType = keyof Maplibre.MapEventType;
|
|
27
|
+
type LayerEventType = keyof Maplibre.MapLayerEventType;
|
|
28
|
+
/**
|
|
29
|
+
* The map of the enclosing `MMap`, for your own controls, layers and handlers (call it in a component inside
|
|
30
|
+
* `MMap`). Listeners added through it are removed when the component unmounts.
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* const { map, onLayer } = useMap()
|
|
34
|
+
* onLayer('click', 'parcels-fill', (e) => console.log(e.features?.[0]?.properties))
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function useMap(): {
|
|
38
|
+
map: ComputedRef<Maplibre.Map | undefined>;
|
|
39
|
+
maplibre: ComputedRef<MaplibreModule | undefined>;
|
|
40
|
+
styleVersion: ComputedRef<number>;
|
|
41
|
+
/** The tool that owns the map's clicks (null: none): set it while yours does, and leave it alone otherwise */
|
|
42
|
+
activeTool: Ref<string | null, string | null>;
|
|
43
|
+
onReady: (fn: (map: Maplibre.Map, maplibre: MaplibreModule) => void) => void;
|
|
44
|
+
on: <T extends MapEventType>(type: T, listener: (e: Maplibre.MapEventType[T] & object) => void) => void;
|
|
45
|
+
onLayer: <T extends LayerEventType>(type: T, layerId: string, listener: (e: Maplibre.MapLayerEventType[T] & object) => void) => void;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as Maplibre from 'maplibre-gl';
|
|
2
|
+
/**
|
|
3
|
+
* Filters for the layers of the enclosing `MMap`, on top of the filters their style already has (a layer that only
|
|
4
|
+
* draws parks keeps doing so): `setFilter(layer, expression)` combines both, `setFilter(layer, null)` brings the
|
|
5
|
+
* style's back. `MMapFilter` is built on it; use it for filters of your own (a range slider, a date, a search…).
|
|
6
|
+
*/
|
|
7
|
+
export declare function useMapFilter(): {
|
|
8
|
+
setFilter: (layerId: string, filter: Maplibre.FilterSpecification | null) => void;
|
|
9
|
+
valuesOf: (layerId: string, property: string) => (string | number)[];
|
|
10
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type * as Maplibre from 'maplibre-gl';
|
|
2
|
+
import type { MapLayerInfo, MapLayerModel } from './mapAdapters';
|
|
3
|
+
/** Visibility and opacity of the model's layers, shared by everything inside one `MMap`. */
|
|
4
|
+
export interface MapLayerState {
|
|
5
|
+
visible: Record<string, boolean>;
|
|
6
|
+
opacity: Record<string, number>;
|
|
7
|
+
}
|
|
8
|
+
export declare function createLayerState(): MapLayerState;
|
|
9
|
+
export declare function readLayerState(state: MapLayerState, map: Maplibre.Map, model: MapLayerModel | undefined): void;
|
|
10
|
+
/**
|
|
11
|
+
* The layers of the enclosing `MMap`'s style as its `adapter` describes them, with their visibility and opacity, for a
|
|
12
|
+
* layer panel or a base layer switcher of your own (`MMapLayers` and `MMapBaseLayers` are built on it). Changes go to
|
|
13
|
+
* the map and to every component using it; a layer's `children` follow it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useMapLayers(): {
|
|
16
|
+
/** The adapter's model (undefined without an `adapter`) */
|
|
17
|
+
model: import("vue").ComputedRef<MapLayerModel | undefined>;
|
|
18
|
+
layers: import("vue").ComputedRef<MapLayerInfo[]>;
|
|
19
|
+
isVisible: (id: string) => boolean;
|
|
20
|
+
setVisible: (id: string, visible: boolean) => void;
|
|
21
|
+
toggle: (id: string) => void;
|
|
22
|
+
opacityOf: (id: string) => number;
|
|
23
|
+
setOpacity: (id: string, opacity: number) => void;
|
|
24
|
+
layersOf: (group: string | null) => MapLayerInfo[];
|
|
25
|
+
groupState: (group: string) => "visible" | "hidden" | "partial";
|
|
26
|
+
setGroupVisible: (group: string, visible: boolean) => void;
|
|
27
|
+
baseLayers: import("vue").ComputedRef<MapLayerInfo[]>;
|
|
28
|
+
baseLayer: import("vue").ComputedRef<string | null>;
|
|
29
|
+
setBaseLayer: (id: string | null) => void;
|
|
30
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { THEME_KEY } from './_storageKeys';
|
|
1
2
|
export type Theme = 'light' | 'dark' | 'system';
|
|
2
|
-
export
|
|
3
|
+
export { THEME_KEY };
|
|
3
4
|
export declare function useTheme(): {
|
|
4
5
|
theme: import("vue").Ref<Theme, Theme>;
|
|
5
6
|
cycle: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { createM3UI } from './plugin';
|
|
2
2
|
export type { M3UIOptions } from './plugin';
|
|
3
|
+
export type { M3InitialState } from './composables/_ssrState';
|
|
3
4
|
export { useTheme } from './composables/useTheme';
|
|
4
5
|
export type { Theme } from './composables/useTheme';
|
|
5
6
|
export { useColorPalette, palettes } from './composables/useColorPalette';
|
|
6
|
-
export type { Palette, ActiveSeed, ContrastLevel } from './composables/useColorPalette';
|
|
7
|
+
export type { Palette, PaletteId, ActiveSeed, ContrastLevel } from './composables/useColorPalette';
|
|
7
8
|
export { SEED_PALETTE } from './composables/useColorPalette';
|
|
8
9
|
export { themeInitScript } from './composables/themeInitScript';
|
|
9
10
|
export type { ThemeInitOptions } from './composables/themeInitScript';
|