@m3ui-vue/m3ui-vue 1.0.1 → 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.
Files changed (115) hide show
  1. package/dist/API.md +636 -20
  2. package/dist/MMenuItem-DFyXflk9.js +707 -0
  3. package/dist/MMenuItem-DFyXflk9.js.map +1 -0
  4. package/dist/MSlider-CdNIH7jc.js +1376 -0
  5. package/dist/MSlider-CdNIH7jc.js.map +1 -0
  6. package/dist/MTextField-B4X92vH_.js +671 -0
  7. package/dist/MTextField-B4X92vH_.js.map +1 -0
  8. package/dist/api.json +1 -1
  9. package/dist/chart.js +1 -1
  10. package/dist/chart.js.map +1 -1
  11. package/dist/code-editor.js +1 -1
  12. package/dist/components/MIconButton.vue.d.ts +1 -1
  13. package/dist/components/MMap.vue.d.ts +74 -0
  14. package/dist/components/MMapBaseLayers.vue.d.ts +15 -0
  15. package/dist/components/MMapControl.vue.d.ts +23 -0
  16. package/dist/components/MMapFeatureInfo.vue.d.ts +25 -0
  17. package/dist/components/MMapFilter.vue.d.ts +19 -0
  18. package/dist/components/MMapGeoJson.vue.d.ts +34 -0
  19. package/dist/components/MMapHover.vue.d.ts +17 -0
  20. package/dist/components/MMapIdentify.vue.d.ts +37 -0
  21. package/dist/components/MMapLayers.vue.d.ts +31 -0
  22. package/dist/components/MMapMarker.vue.d.ts +42 -0
  23. package/dist/components/MMapMeasure.vue.d.ts +43 -0
  24. package/dist/components/MMapPopup.vue.d.ts +43 -0
  25. package/dist/components/MMapSearch.vue.d.ts +28 -0
  26. package/dist/components/MShader.vue.d.ts +9 -3
  27. package/dist/components/_MMapLayerItem.vue.d.ts +25 -0
  28. package/dist/composables/_hydration.d.ts +4 -0
  29. package/dist/composables/_mapGeometry.d.ts +13 -0
  30. package/dist/composables/_ssrState.d.ts +30 -0
  31. package/dist/composables/_storageKeys.d.ts +3 -0
  32. package/dist/composables/_useThemeTokens.d.ts +7 -0
  33. package/dist/composables/mapAdapters.d.ts +111 -0
  34. package/dist/composables/mapSearch.d.ts +31 -0
  35. package/dist/composables/themeInitScript.d.ts +22 -0
  36. package/dist/composables/useColorPalette.d.ts +176 -6
  37. package/dist/composables/useLocale.d.ts +30 -0
  38. package/dist/composables/useMap.d.ts +47 -0
  39. package/dist/composables/useMapFilter.d.ts +10 -0
  40. package/dist/composables/useMapLayers.d.ts +30 -0
  41. package/dist/composables/useTheme.d.ts +2 -0
  42. package/dist/index.d.ts +4 -1
  43. package/dist/locales/index.js +217 -7
  44. package/dist/locales/index.js.map +1 -1
  45. package/dist/m3ui-vue.css +1 -1
  46. package/dist/m3ui.js +6742 -7961
  47. package/dist/m3ui.js.map +1 -1
  48. package/dist/map.d.ts +24 -0
  49. package/dist/map.js +1931 -0
  50. package/dist/map.js.map +1 -0
  51. package/dist/plugin.d.ts +25 -2
  52. package/dist/rich-text-editor.js +27 -26
  53. package/dist/rich-text-editor.js.map +1 -1
  54. package/dist/styles.css +1 -1
  55. package/dist/{useLocale-CuvWRZ1h.js → useLocale-b5-hzsL3.js} +32 -2
  56. package/dist/useLocale-b5-hzsL3.js.map +1 -0
  57. package/package.json +11 -2
  58. package/src/__tests__/MFab.test.ts +52 -6
  59. package/src/__tests__/MMap.test.ts +292 -0
  60. package/src/__tests__/MMapLayers.test.ts +257 -0
  61. package/src/__tests__/MMapTools.test.ts +233 -0
  62. package/src/__tests__/MShader.test.ts +16 -0
  63. package/src/__tests__/_fakeMaplibre.ts +158 -0
  64. package/src/__tests__/hydration.test.ts +119 -0
  65. package/src/__tests__/ssr.test.ts +171 -0
  66. package/src/__tests__/ssrState.test.ts +155 -0
  67. package/src/__tests__/themeInitScript.test.ts +122 -0
  68. package/src/components/MChart.vue +3 -2
  69. package/src/components/MFab.vue +29 -7
  70. package/src/components/MIconButton.vue +1 -1
  71. package/src/components/MLightbox.vue +10 -1
  72. package/src/components/MMap.vue +522 -0
  73. package/src/components/MMapBaseLayers.vue +67 -0
  74. package/src/components/MMapControl.vue +61 -0
  75. package/src/components/MMapFeatureInfo.vue +41 -0
  76. package/src/components/MMapFilter.vue +80 -0
  77. package/src/components/MMapGeoJson.vue +136 -0
  78. package/src/components/MMapHover.vue +131 -0
  79. package/src/components/MMapIdentify.vue +103 -0
  80. package/src/components/MMapLayers.vue +111 -0
  81. package/src/components/MMapMarker.vue +102 -0
  82. package/src/components/MMapMeasure.vue +452 -0
  83. package/src/components/MMapPopup.vue +99 -0
  84. package/src/components/MMapSearch.vue +162 -0
  85. package/src/components/MSearchBar.vue +4 -1
  86. package/src/components/MShader.vue +11 -3
  87. package/src/components/_MMapLayerItem.vue +77 -0
  88. package/src/composables/_hydration.ts +10 -0
  89. package/src/composables/_mapGeometry.ts +75 -0
  90. package/src/composables/_ssrState.ts +80 -0
  91. package/src/composables/_storageKeys.ts +6 -0
  92. package/src/composables/_useThemeTokens.ts +42 -0
  93. package/src/composables/mapAdapters.ts +208 -0
  94. package/src/composables/mapSearch.ts +56 -0
  95. package/src/composables/themeInitScript.ts +51 -0
  96. package/src/composables/useColorPalette.ts +32 -14
  97. package/src/composables/useLocale.ts +62 -0
  98. package/src/composables/useMap.ts +98 -0
  99. package/src/composables/useMapFilter.ts +45 -0
  100. package/src/composables/useMapLayers.ts +124 -0
  101. package/src/composables/useTheme.ts +18 -7
  102. package/src/composables/useWindowSizeClass.ts +23 -4
  103. package/src/index.ts +4 -1
  104. package/src/locales/de.ts +31 -1
  105. package/src/locales/es.ts +31 -1
  106. package/src/locales/fr.ts +31 -1
  107. package/src/locales/ja.ts +31 -1
  108. package/src/locales/ko.ts +31 -1
  109. package/src/locales/pt.ts +31 -1
  110. package/src/locales/zh.ts +31 -1
  111. package/src/map.ts +32 -0
  112. package/src/plugin.ts +77 -13
  113. package/dist/MTextField-BPbFeI9M.js +0 -1368
  114. package/dist/MTextField-BPbFeI9M.js.map +0 -1
  115. package/dist/useLocale-CuvWRZ1h.js.map +0 -1
@@ -0,0 +1,30 @@
1
+ import { type InjectionKey, type Ref } from 'vue';
2
+ import type { Theme } from './useTheme';
3
+ import type { ContrastLevel } from './useColorPalette';
4
+ /** The user's theme choices as a server knows them (from cookies), for server-side rendering. */
5
+ export interface M3InitialState {
6
+ theme?: Theme;
7
+ palette?: string;
8
+ contrast?: ContrastLevel;
9
+ /** The browser window's size: the adaptive layouts and `useWindowSizeClass()` render for it instead of compact. */
10
+ viewport?: {
11
+ width: number;
12
+ height: number;
13
+ };
14
+ }
15
+ /** `initialState` with the plugin's defaults filled in (the viewport stays optional: there's no default for it). */
16
+ export type ResolvedInitialState = Required<Omit<M3InitialState, 'viewport'>> & Pick<M3InitialState, 'viewport'>;
17
+ export declare const M3_INITIAL_STATE_KEY: InjectionKey<ResolvedInitialState>;
18
+ export declare function initialState(): ResolvedInitialState | null;
19
+ /**
20
+ * What a composable reports for a stored choice. On the server: the initial state (the module-level refs are shared
21
+ * by every request and hold nothing there). On the client while hydrating: the initial state too, so the first
22
+ * render matches the server's HTML, then the live value once mounted. Otherwise the live ref itself.
23
+ */
24
+ export declare function ssrValue<T>(live: Ref<T>, initial: T | undefined): Ref<T>;
25
+ export declare function enableCookies(): void;
26
+ /** Keeps the window's size in a cookie, for the server to render the adaptive layouts at it. */
27
+ export declare function trackViewport(): void;
28
+ /** A cookie's value: the stored choice when localStorage has none (cleared storage, or a server that set it). */
29
+ export declare function readCookie(key: string): string | null;
30
+ export declare function writeCookie(key: string, value: string | null): void;
@@ -0,0 +1,3 @@
1
+ export declare const THEME_KEY = "m3-theme";
2
+ export declare const STYLE_ID = "m3-dynamic-palette";
3
+ export declare const VIEWPORT_KEY = "m3-viewport";
@@ -0,0 +1,7 @@
1
+ import { type Ref } from 'vue';
2
+ /**
3
+ * The current values of some color tokens (`['primary', 'surface']` → `--color-primary`…), kept up to date across
4
+ * theme, palette and contrast changes: for what can't use CSS variables (a MapLibre layer's paint, a canvas). Empty
5
+ * strings on the server.
6
+ */
7
+ export declare function useThemeTokens<T extends string>(names: readonly T[]): Ref<Record<T, string>>;
@@ -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;
@@ -0,0 +1,22 @@
1
+ import { type ContrastLevel, type PaletteId } from './useColorPalette';
2
+ export interface ThemeInitOptions {
3
+ /** `createM3UI`'s `palette`: the first-visit default, or forced with `persistPalette: false`. */
4
+ palette?: PaletteId | (string & {});
5
+ /** `createM3UI`'s `contrast`, with the same rules as `palette`. */
6
+ contrast?: ContrastLevel;
7
+ /** `createM3UI`'s `persistPalette`. */
8
+ persistPalette?: boolean;
9
+ }
10
+ /**
11
+ * A script to inline in `<head>` of a server-rendered page (Nuxt, Vite SSR), so dark mode, the palette and the
12
+ * contrast level are on `<html>` before the first paint instead of when the app's JS loads. It does what
13
+ * `useTheme` and `useColorPalette` do when they load in the browser (the stored choice, or the given
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
16
+ * early: its first visit still shows the baseline until the app loads (later visits use the cached CSS).
17
+ *
18
+ * ```ts
19
+ * useHead({ script: [{ innerHTML: themeInitScript({ palette: 'red' }) }] })
20
+ * ```
21
+ */
22
+ export declare function themeInitScript(options?: ThemeInitOptions): string;
@@ -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,22 +10,190 @@ 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";
14
180
  export interface ActiveSeed extends SeedOptions {
15
181
  seed: string;
16
182
  }
183
+ export declare const PALETTE_KEY = "m3-palette";
184
+ export declare const CONTRAST_KEY = "m3-contrast";
185
+ export declare const CSS_KEY = "m3-palette-css";
17
186
  /**
18
187
  * M3's contrast levels. `system` follows the OS (`prefers-contrast: more` → high). Built-in palettes need
19
188
  * `@m3ui-vue/m3ui-vue/palettes-contrast` imported for medium and high; seed palettes are regenerated.
20
189
  */
21
190
  export type ContrastLevel = 'standard' | 'medium' | 'high' | 'system';
191
+ export { STYLE_ID };
22
192
  export declare function useColorPalette(): {
23
- palette: import("vue").Ref<string, string>;
193
+ palette: Ref<string, string>;
24
194
  palettes: Palette[];
25
- set: (id: string) => void;
26
- seed: Readonly<import("vue").Ref<{
195
+ set: (id: PaletteId | (string & {})) => void;
196
+ seed: Readonly<Ref<{
27
197
  readonly seed: string;
28
198
  readonly variant?: import("./dynamicColor").SchemeVariant | undefined;
29
199
  readonly contrast?: number | undefined;
@@ -33,10 +203,10 @@ export declare function useColorPalette(): {
33
203
  readonly contrast?: number | undefined;
34
204
  } | null>>;
35
205
  setSeed: (seed: string, options?: SeedOptions) => Promise<void>;
36
- contrast: Readonly<import("vue").Ref<ContrastLevel, ContrastLevel>>;
37
- activeContrast: import("vue").ComputedRef<"medium" | "standard" | "high">;
206
+ contrast: Readonly<Ref<ContrastLevel>>;
207
+ activeContrast: Ref<"medium" | "standard" | "high", "medium" | "standard" | "high">;
38
208
  setContrast: (level: ContrastLevel) => void;
39
- persistPalette: import("vue").Ref<boolean, boolean>;
209
+ persistPalette: Ref<boolean, boolean>;
40
210
  setPersistPalette: (enabled: boolean) => void;
41
211
  };
42
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,4 +1,6 @@
1
+ import { THEME_KEY } from './_storageKeys';
1
2
  export type Theme = 'light' | 'dark' | 'system';
3
+ export { THEME_KEY };
2
4
  export declare function useTheme(): {
3
5
  theme: import("vue").Ref<Theme, Theme>;
4
6
  cycle: () => void;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,13 @@
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';
9
+ export { themeInitScript } from './composables/themeInitScript';
10
+ export type { ThemeInitOptions } from './composables/themeInitScript';
8
11
  export { generateScheme, schemeToCss, schemeRoles } from './composables/dynamicColor';
9
12
  export type { SchemeVariant, SeedOptions, GeneratedScheme } from './composables/dynamicColor';
10
13
  export { useToast } from './composables/useToast';