@leavepulse/ui 0.16.2 → 0.17.1

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 (51) hide show
  1. package/dist/chunks/LpAddressInput-ChT1JQg0.js +366 -0
  2. package/dist/chunks/{LpAppShell-CV194os6.js → LpAppShell-C6Mj82LS.js} +2 -2
  3. package/dist/chunks/{LpConfirmDialog-DnReh5pF.js → LpConfirmDialog-3_Qu4hnA.js} +1 -1
  4. package/dist/chunks/{LpDrawer-BHzCy-Aa.js → LpDrawer-Fxk7ViQ-.js} +1 -1
  5. package/dist/chunks/{LpFileTree-YOJCuIjJ.js → LpFileTree-CXg3KDth.js} +1 -1
  6. package/dist/chunks/{LpLogViewer-BvzRZPjs.js → LpLogViewer-D7DNEYaG.js} +1 -1
  7. package/dist/chunks/LpMapPicker-DFKrd1Ne.js +509 -0
  8. package/dist/chunks/{LpModal-CezA8eJ3.js → LpModal-J-KRPO7F.js} +1 -1
  9. package/dist/chunks/{LpNotificationBell-BtfRoL2i.js → LpNotificationBell-D8sdQLgu.js} +26 -13
  10. package/dist/chunks/{LpScrollArea-De9DLpa1.js → LpScrollArea-CKhOx0_l.js} +2 -2
  11. package/dist/chunks/{LpSidebar-B11IDRQi.js → LpSidebar-Bk7SrINq.js} +2 -2
  12. package/dist/chunks/{LpSidebarNav-TIUNHZX-.js → LpSidebarNav-Cpd-yHXb.js} +1 -1
  13. package/dist/chunks/{LpTable-CKGaUbEM.js → LpTable-X3ieZmbr.js} +1 -1
  14. package/dist/chunks/{LpThemeSwitcher-BgWwfkxs.js → LpThemeSwitcher-DC6QygnU.js} +11 -3
  15. package/dist/component-names.d.ts +1 -1
  16. package/dist/components/LpAddressInput.vue.d.ts +53 -0
  17. package/dist/components/LpAddressInput.vue.js +4 -0
  18. package/dist/components/LpAlert.vue.d.ts +1 -1
  19. package/dist/components/LpAppShell.vue.js +1 -1
  20. package/dist/components/LpCommandPalette.vue.js +1 -1
  21. package/dist/components/LpConfirmDialog.vue.js +1 -1
  22. package/dist/components/LpDrawer.vue.js +1 -1
  23. package/dist/components/LpFileTree.vue.d.ts +2 -2
  24. package/dist/components/LpFileTree.vue.js +1 -1
  25. package/dist/components/LpLightbox.vue.d.ts +1 -1
  26. package/dist/components/LpLogViewer.vue.js +1 -1
  27. package/dist/components/LpMapPicker.vue.d.ts +44 -0
  28. package/dist/components/LpMapPicker.vue.js +4 -0
  29. package/dist/components/LpModal.vue.js +1 -1
  30. package/dist/components/LpNotificationBell.vue.d.ts +22 -0
  31. package/dist/components/LpNotificationBell.vue.js +1 -1
  32. package/dist/components/LpScrollArea.vue.js +1 -1
  33. package/dist/components/LpSidebar.vue.js +1 -1
  34. package/dist/components/LpSidebarNav.vue.js +1 -1
  35. package/dist/components/LpTable.vue.js +1 -1
  36. package/dist/components/LpThemeSwitcher.vue.d.ts +7 -0
  37. package/dist/components/LpThemeSwitcher.vue.js +1 -1
  38. package/dist/components/address.d.ts +107 -0
  39. package/dist/components/address.js +96 -0
  40. package/dist/index.d.ts +5 -1
  41. package/dist/index.js +129 -117
  42. package/package.json +1 -1
  43. package/src/component-names.ts +2 -0
  44. package/src/components/LpAddressInput.vue +377 -0
  45. package/src/components/LpMapPicker.vue +665 -0
  46. package/src/components/LpNotificationBell.vue +47 -9
  47. package/src/components/LpScrollArea.vue +8 -2
  48. package/src/components/LpThemeSwitcher.vue +24 -2
  49. package/src/components/address.ts +250 -0
  50. package/src/index.ts +194 -169
  51. package/src/theme/presets.ts +8 -2
@@ -2,7 +2,7 @@ import { defineComponent, computed, ref, watch, onBeforeUnmount, openBlock, crea
2
2
  import { _ as _sfc_main$2 } from "./LpCheckbox-BO0zuuPh.js";
3
3
  import { _ as _sfc_main$4 } from "./LpContextMenu-D0mzXqA7.js";
4
4
  import { _ as _sfc_main$3 } from "./LpIcon-CCnX5_2j.js";
5
- import { _ as _sfc_main$1 } from "./LpScrollArea-De9DLpa1.js";
5
+ import { _ as _sfc_main$1 } from "./LpScrollArea-CKhOx0_l.js";
6
6
  const _hoisted_1 = { class: "w-full border-collapse text-sm" };
7
7
  const _hoisted_2 = { class: "border-b border-line bg-surface-soft" };
8
8
  const _hoisted_3 = {
@@ -8,7 +8,7 @@ const interFont = {
8
8
  mono: '"JetBrains Mono", "SF Mono", ui-monospace, monospace'
9
9
  };
10
10
  const dark = {
11
- name: "Dark",
11
+ name: "Onyx",
12
12
  mode: "dark",
13
13
  colors: {
14
14
  surface: "#080b0d",
@@ -105,7 +105,7 @@ const glassSurface = {
105
105
  panelInset: "inset 0 1px 0 rgba(255, 255, 255, 0.08)"
106
106
  };
107
107
  const leavepulse = {
108
- name: "LeavePulse",
108
+ name: "Dark",
109
109
  mode: "dark",
110
110
  colors: {
111
111
  surface: "#020618",
@@ -480,6 +480,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
480
480
  props: {
481
481
  modelValue: {},
482
482
  themes: {},
483
+ cycleThemes: {},
483
484
  variant: { default: "swatch" },
484
485
  showLabel: { type: Boolean },
485
486
  default: {},
@@ -519,8 +520,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
519
520
  emit("update:modelValue", t.name);
520
521
  emit("change", t);
521
522
  }
523
+ const cycleList = computed(() => {
524
+ if (!props.cycleThemes?.length) return list.value;
525
+ const resolved = props.cycleThemes.map(
526
+ (t) => typeof t === "string" ? list.value.find((x) => x.name === t) : t
527
+ ).filter((t) => Boolean(t));
528
+ return resolved.length ? resolved : list.value;
529
+ });
522
530
  function cycle(ev) {
523
- const arr = list.value;
531
+ const arr = cycleList.value;
524
532
  if (!arr.length) return;
525
533
  const i = arr.findIndex((t) => t.name === activeName.value);
526
534
  const next = arr[(i + 1) % arr.length];
@@ -1 +1 @@
1
- export declare const COMPONENT_NAMES: readonly ["LayoutCanvas", "LayoutNode", "LpAlert", "LpAppShell", "LpAutocomplete", "LpAvatar", "LpBadge", "LpBreadcrumbs", "LpButton", "LpCalendar", "LpCard", "LpCheckbox", "LpCodeBlock", "LpCommandPalette", "LpConfirmDialog", "LpContextMenu", "LpDatePicker", "LpDisclosure", "LpDivider", "LpDrawer", "LpDropdownMenu", "LpEmptyState", "LpFileTree", "LpFileTreeNode", "LpFormField", "LpIcon", "LpInfraNode", "LpInput", "LpLaneNode", "LpLightbox", "LpLink", "LpLogViewer", "LpModal", "LpNotificationBell", "LpNumberField", "LpOtpInput", "LpPagination", "LpPasswordInput", "LpPhoneInput", "LpPopover", "LpProgress", "LpRadio", "LpRadioGroup", "LpScrollArea", "LpSegmented", "LpSelect", "LpServiceNode", "LpSidebar", "LpSidebarNav", "LpSkeleton", "LpSlider", "LpStat", "LpStepper", "LpSwitch", "LpTable", "LpTableOfContents", "LpTabs", "LpTextarea", "LpThemeSwitcher", "LpTilt", "LpToaster", "LpTooltip", "LpTopologyCanvas", "LpUptimeBar"];
1
+ export declare const COMPONENT_NAMES: readonly ["LayoutCanvas", "LayoutNode", "LpAddressInput", "LpAlert", "LpAppShell", "LpAutocomplete", "LpAvatar", "LpBadge", "LpBreadcrumbs", "LpButton", "LpCalendar", "LpCard", "LpCheckbox", "LpCodeBlock", "LpCommandPalette", "LpConfirmDialog", "LpContextMenu", "LpDatePicker", "LpDisclosure", "LpDivider", "LpDrawer", "LpDropdownMenu", "LpEmptyState", "LpFileTree", "LpFileTreeNode", "LpFormField", "LpIcon", "LpInfraNode", "LpInput", "LpLaneNode", "LpLightbox", "LpLink", "LpLogViewer", "LpMapPicker", "LpModal", "LpNotificationBell", "LpNumberField", "LpOtpInput", "LpPagination", "LpPasswordInput", "LpPhoneInput", "LpPopover", "LpProgress", "LpRadio", "LpRadioGroup", "LpScrollArea", "LpSegmented", "LpSelect", "LpServiceNode", "LpSidebar", "LpSidebarNav", "LpSkeleton", "LpSlider", "LpStat", "LpStepper", "LpSwitch", "LpTable", "LpTableOfContents", "LpTabs", "LpTextarea", "LpThemeSwitcher", "LpTilt", "LpToaster", "LpTooltip", "LpTopologyCanvas", "LpUptimeBar"];
@@ -0,0 +1,53 @@
1
+ import { AddressLabels, AddressValue, GeocodeProvider, LatLon, TileSource } from './address';
2
+ type __VLS_Props = {
3
+ /** The address. Bind with v-model. */
4
+ modelValue?: AddressValue;
5
+ /** Geocoder for suggestions and for the map's reverse lookup. */
6
+ provider?: GeocodeProvider;
7
+ /** Tile server handed to the built-in picker. */
8
+ tiles?: TileSource;
9
+ /** Restrict the country list (ISO2). Omit for every country. */
10
+ only?: string[];
11
+ /** Show the "apartment, suite" line. */
12
+ secondLine?: boolean;
13
+ /** Suggestions start after this many characters. */
14
+ minChars?: number;
15
+ /** Debounce before a suggestion request goes out. */
16
+ debounce?: number;
17
+ /** Accept-Language for the geocoder. */
18
+ language?: string;
19
+ disabled?: boolean;
20
+ size?: "sm" | "md" | "lg";
21
+ /** Hide the map button when picking a point makes no sense. */
22
+ hideMap?: boolean;
23
+ labels?: Partial<AddressLabels>;
24
+ };
25
+ declare function onPick(next: LatLon): Promise<void>;
26
+ declare var __VLS_88: {
27
+ point: LatLon | undefined;
28
+ setPoint: typeof onPick;
29
+ tiles: TileSource;
30
+ };
31
+ type __VLS_Slots = {} & {
32
+ map?: (props: typeof __VLS_88) => any;
33
+ };
34
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
35
+ "update:modelValue": (value: AddressValue) => any;
36
+ pick: (value: LatLon) => any;
37
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
38
+ "onUpdate:modelValue"?: ((value: AddressValue) => any) | undefined;
39
+ onPick?: ((value: LatLon) => any) | undefined;
40
+ }>, {
41
+ size: "sm" | "md" | "lg";
42
+ minChars: number;
43
+ tiles: TileSource;
44
+ debounce: number;
45
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
46
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
47
+ declare const _default: typeof __VLS_export;
48
+ export default _default;
49
+ type __VLS_WithSlots<T, S> = T & {
50
+ new (): {
51
+ $slots: S;
52
+ };
53
+ };
@@ -0,0 +1,4 @@
1
+ import { _ as _sfc_main } from "../chunks/LpAddressInput-ChT1JQg0.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -32,7 +32,7 @@ type __VLS_Slots = {} & {
32
32
  default?: (props: typeof __VLS_6) => any;
33
33
  };
34
34
  declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
35
- variant: "info" | "success" | "warning" | "danger";
35
+ variant: "info" | "danger" | "success" | "warning";
36
36
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
37
37
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
38
38
  declare const _default: typeof __VLS_export;
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpAppShell-CV194os6.js";
1
+ import { _ as _sfc_main } from "../chunks/LpAppShell-C6Mj82LS.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, ref, computed, watch, nextTick, onMounted, onBeforeUnmount, openBlock, createBlock, unref, withCtx, createVNode, withModifiers, createTextVNode, createElementVNode, withDirectives, withKeys, vModelText, createElementBlock, toDisplayString, createCommentVNode, Fragment, renderList, normalizeClass } from "vue";
2
2
  import { DialogRoot, DialogPortal, DialogOverlay, DialogContent, DialogTitle, DialogDescription } from "reka-ui";
3
3
  import { _ as _sfc_main$1 } from "../chunks/LpIcon-CCnX5_2j.js";
4
- import { _ as _sfc_main$2 } from "../chunks/LpScrollArea-De9DLpa1.js";
4
+ import { _ as _sfc_main$2 } from "../chunks/LpScrollArea-CKhOx0_l.js";
5
5
  import '../assets/LpCommandPalette-D315B47-.css';const _hoisted_1 = { class: "flex shrink-0 items-center gap-2.5 border-b border-line px-4" };
6
6
  const _hoisted_2 = ["placeholder", "onKeydown"];
7
7
  const _hoisted_3 = {
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpConfirmDialog-DnReh5pF.js";
1
+ import { _ as _sfc_main } from "../chunks/LpConfirmDialog-3_Qu4hnA.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpDrawer-BHzCy-Aa.js";
1
+ import { _ as _sfc_main } from "../chunks/LpDrawer-Fxk7ViQ-.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -72,18 +72,18 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {
72
72
  select: (node: FileNode) => any;
73
73
  summary: (summary: FileTreeSummary) => any;
74
74
  open: (node: FileNode) => any;
75
+ collapse: (node: FileNode) => any;
75
76
  "update:selected": (id: string) => any;
76
77
  "update:expanded": (ids: string[]) => any;
77
- collapse: (node: FileNode) => any;
78
78
  "update:checked": (ids: string[]) => any;
79
79
  }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
80
80
  onExpand?: ((node: FileNode) => any) | undefined;
81
81
  onSelect?: ((node: FileNode) => any) | undefined;
82
82
  onSummary?: ((summary: FileTreeSummary) => any) | undefined;
83
83
  onOpen?: ((node: FileNode) => any) | undefined;
84
+ onCollapse?: ((node: FileNode) => any) | undefined;
84
85
  "onUpdate:selected"?: ((id: string) => any) | undefined;
85
86
  "onUpdate:expanded"?: ((ids: string[]) => any) | undefined;
86
- onCollapse?: ((node: FileNode) => any) | undefined;
87
87
  "onUpdate:checked"?: ((ids: string[]) => any) | undefined;
88
88
  }>, {
89
89
  sort: boolean;
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpFileTree-YOJCuIjJ.js";
1
+ import { _ as _sfc_main } from "../chunks/LpFileTree-CXg3KDth.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -46,11 +46,11 @@ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {},
46
46
  }>, {
47
47
  loop: boolean;
48
48
  open: boolean;
49
+ maxZoom: number;
49
50
  copyable: boolean;
50
51
  index: number;
51
52
  rotatable: boolean;
52
53
  downloadable: boolean;
53
- maxZoom: number;
54
54
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
55
55
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
56
56
  declare const _default: typeof __VLS_export;
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpLogViewer-BvzRZPjs.js";
1
+ import { _ as _sfc_main } from "../chunks/LpLogViewer-D7DNEYaG.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -0,0 +1,44 @@
1
+ import { LatLon, TileSource } from './address';
2
+ type __VLS_Props = {
3
+ /** Picked point. Bind with v-model; undefined leaves the map unpinned. */
4
+ modelValue?: LatLon;
5
+ /** Tile server. Defaults to OpenStreetMap; swap for your own. */
6
+ tiles?: TileSource;
7
+ /** Zoom used on first paint, and when a point arrives from outside. */
8
+ zoom?: number;
9
+ /** Where to look when there is no point yet. */
10
+ center?: LatLon;
11
+ disabled?: boolean;
12
+ /** Any CSS length. */
13
+ height?: string;
14
+ /** Offer the "use my location" control (needs a secure context). */
15
+ locatable?: boolean;
16
+ zoomInLabel?: string;
17
+ zoomOutLabel?: string;
18
+ locateLabel?: string;
19
+ recentreLabel?: string;
20
+ };
21
+ declare function recentre(): void;
22
+ declare function locate(): void;
23
+ declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
24
+ zoomIn: () => void;
25
+ zoomOut: () => void;
26
+ recentre: typeof recentre;
27
+ locate: typeof locate;
28
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
29
+ "update:modelValue": (value: LatLon) => any;
30
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
31
+ "onUpdate:modelValue"?: ((value: LatLon) => any) | undefined;
32
+ }>, {
33
+ center: LatLon;
34
+ height: string;
35
+ zoom: number;
36
+ tiles: TileSource;
37
+ locatable: boolean;
38
+ zoomInLabel: string;
39
+ zoomOutLabel: string;
40
+ locateLabel: string;
41
+ recentreLabel: string;
42
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
43
+ declare const _default: typeof __VLS_export;
44
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import { _ as _sfc_main } from "../chunks/LpMapPicker-DFKrd1Ne.js";
2
+ export {
3
+ _sfc_main as default
4
+ };
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpModal-CezA8eJ3.js";
1
+ import { _ as _sfc_main } from "../chunks/LpModal-J-KRPO7F.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -12,6 +12,21 @@ export interface NotificationItem {
12
12
  /** Whether the notification has been read. */
13
13
  read?: boolean;
14
14
  }
15
+ /**
16
+ * Every user-facing string the bell renders on its own. Apps with i18n pass
17
+ * their translations in; the English defaults keep the component usable bare.
18
+ * Without this the header/row menus would be hardcoded English in every locale.
19
+ */
20
+ export interface NotificationLabels {
21
+ title?: string;
22
+ markAllRead?: string;
23
+ markAsRead?: string;
24
+ markAsUnread?: string;
25
+ open?: string;
26
+ dismiss?: string;
27
+ empty?: string;
28
+ ariaLabel?: string;
29
+ }
15
30
  type __VLS_Props = {
16
31
  items?: NotificationItem[];
17
32
  /** Unread count for the badge; falls back to counting unread items. */
@@ -23,6 +38,13 @@ type __VLS_Props = {
23
38
  maxBadge?: number;
24
39
  /** Right-click menu items; overrides the built-in quick actions. */
25
40
  menuItems?: ContextMenuItemDef[];
41
+ /** Translations for the strings the bell renders itself. */
42
+ labels?: NotificationLabels;
43
+ /**
44
+ * Formats `item.createdAt` for display. Defaults to a compact English
45
+ * relative time ("just now", "5m", "3h"); pass your own to localise it.
46
+ */
47
+ formatTime?: (iso: string) => string;
26
48
  };
27
49
  type __VLS_ModelProps = {
28
50
  "open"?: boolean;
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpNotificationBell-BtfRoL2i.js";
1
+ import { _ as _sfc_main } from "../chunks/LpNotificationBell-D8sdQLgu.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpScrollArea-De9DLpa1.js";
1
+ import { _ as _sfc_main } from "../chunks/LpScrollArea-CKhOx0_l.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpSidebar-B11IDRQi.js";
1
+ import { _ as _sfc_main } from "../chunks/LpSidebar-Bk7SrINq.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpSidebarNav-TIUNHZX-.js";
1
+ import { _ as _sfc_main } from "../chunks/LpSidebarNav-Cpd-yHXb.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpTable-CKGaUbEM.js";
1
+ import { _ as _sfc_main } from "../chunks/LpTable-X3ieZmbr.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -4,6 +4,13 @@ type __VLS_Props = {
4
4
  modelValue?: string;
5
5
  /** Themes to offer. Defaults to all built-in presets. */
6
6
  themes?: TokenSet[];
7
+ /**
8
+ * Themes the LEFT-click cycles through — names from `themes`, or TokenSets.
9
+ * Defaults to the full list (cycle everything). Pass two, e.g.
10
+ * `:cycle-themes="['Dark', 'Light']"`, for a quick dark/light toggle while
11
+ * the right-click menu still offers every theme.
12
+ */
13
+ cycleThemes?: (string | TokenSet)[];
7
14
  /**
8
15
  * Trigger style:
9
16
  * - "swatch" (default): a square showing the active theme's brand colour.
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main } from "../chunks/LpThemeSwitcher-BgWwfkxs.js";
1
+ import { _ as _sfc_main } from "../chunks/LpThemeSwitcher-DC6QygnU.js";
2
2
  export {
3
3
  _sfc_main as default
4
4
  };
@@ -0,0 +1,107 @@
1
+ export interface LatLon {
2
+ lat: number;
3
+ lon: number;
4
+ }
5
+ export interface AddressValue {
6
+ /** Street and house number, e.g. "Baker Street 221B". */
7
+ line: string;
8
+ /** Apartment, suite, floor — only shown when LpAddressInput asks for it. */
9
+ line2?: string;
10
+ city: string;
11
+ postalCode: string;
12
+ /** ISO 3166-1 alpha-2, uppercase — same shape LpPhoneInput uses. */
13
+ country: string;
14
+ /** Set once a point is picked on the map or a suggestion carries one. */
15
+ lat?: number;
16
+ lon?: number;
17
+ }
18
+ export declare function emptyAddress(): AddressValue;
19
+ export interface AddressSuggestion {
20
+ /** Text to put in the field that asked for it. */
21
+ value: string;
22
+ label: string;
23
+ /** Fuller context — the whole formatted address, shown under the label. */
24
+ description?: string;
25
+ /** Parsed parts, as much as the provider resolved. */
26
+ address: Partial<AddressValue>;
27
+ lat?: number;
28
+ lon?: number;
29
+ }
30
+ /** Which field is being completed — providers can bias results accordingly. */
31
+ export type AddressField = "line" | "city" | "postalCode";
32
+ export interface GeocodeQuery {
33
+ /** Restrict to a country (ISO2) when the form already has one. */
34
+ country?: string;
35
+ /** Preferred result language, as an Accept-Language value. */
36
+ language?: string;
37
+ limit?: number;
38
+ signal?: AbortSignal;
39
+ }
40
+ export interface GeocodeProvider {
41
+ search(term: string, field: AddressField, query?: GeocodeQuery): Promise<AddressSuggestion[]>;
42
+ /** Point → address. Undefined when the point resolves to nothing. */
43
+ reverse(lat: number, lon: number, query?: GeocodeQuery): Promise<AddressSuggestion | undefined>;
44
+ }
45
+ export interface NominatimOptions {
46
+ /** Base URL of a Nominatim instance, no trailing slash. */
47
+ endpoint?: string;
48
+ language?: string;
49
+ /**
50
+ * Public Nominatim asks for an identifying UA and rate-limits hard; browsers
51
+ * won't let us set User-Agent, so this rides along as `email` instead, which
52
+ * their usage policy accepts. Point `endpoint` at your own instance for
53
+ * anything busier than a settings form.
54
+ */
55
+ email?: string;
56
+ }
57
+ export declare function createNominatimProvider(options?: NominatimOptions): GeocodeProvider;
58
+ /**
59
+ * Every user-facing string in LpAddressInput, so an app can translate it
60
+ * without the kit taking an i18n dependency. Pass a partial — anything absent
61
+ * keeps the English default.
62
+ */
63
+ export interface AddressLabels {
64
+ line: string;
65
+ linePlaceholder: string;
66
+ secondLine: string;
67
+ secondLinePlaceholder: string;
68
+ city: string;
69
+ cityPlaceholder: string;
70
+ postalCode: string;
71
+ postalCodePlaceholder: string;
72
+ country: string;
73
+ countryPlaceholder: string;
74
+ countrySearch: string;
75
+ pickOnMap: string;
76
+ mapTitle: string;
77
+ mapHint: string;
78
+ use: string;
79
+ cancel: string;
80
+ searching: string;
81
+ noSuggestions: string;
82
+ nothingHere: string;
83
+ }
84
+ /** Formats an address the way a shipping label would read. */
85
+ export declare function formatAddress(value: AddressValue, countryName?: string): string;
86
+ export interface TileSource {
87
+ /** Template with {z}/{x}/{y}, plus optional {s} for a subdomain. */
88
+ url: string;
89
+ /** Rendered under the map — most tile terms require crediting the source. */
90
+ attribution?: string;
91
+ subdomains?: string[];
92
+ minZoom?: number;
93
+ maxZoom?: number;
94
+ /** Edge length of one tile in CSS pixels. Default 256. */
95
+ tileSize?: number;
96
+ }
97
+ export declare const OSM_TILES: TileSource;
98
+ export declare function tileUrl(source: TileSource, z: number, x: number, y: number): string;
99
+ export declare const MAX_LATITUDE = 85.05112878;
100
+ export declare function project(lat: number, lon: number, zoom: number, tileSize?: number): {
101
+ x: number;
102
+ y: number;
103
+ };
104
+ export declare function unproject(x: number, y: number, zoom: number, tileSize?: number): {
105
+ lat: number;
106
+ lon: number;
107
+ };
@@ -0,0 +1,96 @@
1
+ function emptyAddress() {
2
+ return { line: "", city: "", postalCode: "", country: "" };
3
+ }
4
+ const NOMINATIM_ENDPOINT = "https://nominatim.openstreetmap.org";
5
+ function createNominatimProvider(options = {}) {
6
+ const endpoint = options.endpoint ?? NOMINATIM_ENDPOINT;
7
+ function common(query, params) {
8
+ params.set("format", "jsonv2");
9
+ params.set("addressdetails", "1");
10
+ if (options.email) params.set("email", options.email);
11
+ if (query?.country) params.set("countrycodes", query.country.toLowerCase());
12
+ }
13
+ async function get(path, params, query) {
14
+ const language = query?.language ?? options.language;
15
+ const res = await fetch(`${endpoint}${path}?${params}`, {
16
+ signal: query?.signal,
17
+ headers: language ? { "Accept-Language": language } : void 0
18
+ });
19
+ if (!res.ok) throw new Error(`geocoder responded ${res.status}`);
20
+ return await res.json();
21
+ }
22
+ return {
23
+ async search(term, field, query) {
24
+ const params = new URLSearchParams({ q: term, limit: String(query?.limit ?? 6) });
25
+ common(query, params);
26
+ const results = await get("/search", params, query);
27
+ return results.map((result) => toSuggestion(result, field));
28
+ },
29
+ async reverse(lat, lon, query) {
30
+ const params = new URLSearchParams({ lat: String(lat), lon: String(lon) });
31
+ common(query, params);
32
+ params.delete("countrycodes");
33
+ const result = await get("/reverse", params, query);
34
+ if (!result || "error" in result) return void 0;
35
+ return toSuggestion(result, "line");
36
+ }
37
+ };
38
+ }
39
+ function toSuggestion(result, field) {
40
+ const parts = result.address ?? {};
41
+ const city = parts.city || parts.town || parts.village || parts.municipality || "";
42
+ const street = [parts.road, parts.house_number].filter(Boolean).join(" ");
43
+ const address = {
44
+ line: street || void 0,
45
+ city: city || void 0,
46
+ postalCode: parts.postcode || void 0,
47
+ country: parts.country_code ? parts.country_code.toUpperCase() : void 0
48
+ };
49
+ const lat = result.lat ? Number(result.lat) : void 0;
50
+ const lon = result.lon ? Number(result.lon) : void 0;
51
+ const value = field === "city" ? city || result.name || result.display_name : field === "postalCode" ? parts.postcode || "" : street || result.name || result.display_name;
52
+ return { value, label: value || result.display_name, description: result.display_name, address, lat, lon };
53
+ }
54
+ function formatAddress(value, countryName) {
55
+ const locality = [value.postalCode, value.city].filter(Boolean).join(" ");
56
+ return [value.line, locality, countryName ?? value.country].filter(Boolean).join(", ");
57
+ }
58
+ const OSM_TILES = {
59
+ url: "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
60
+ attribution: "© OpenStreetMap contributors",
61
+ minZoom: 1,
62
+ maxZoom: 19
63
+ };
64
+ function tileUrl(source, z, x, y) {
65
+ const subdomains = source.subdomains;
66
+ const subdomain = subdomains?.length ? subdomains[Math.abs(x + y) % subdomains.length] : "";
67
+ return source.url.replace("{s}", subdomain).replace("{z}", String(z)).replace("{x}", String(x)).replace("{y}", String(y));
68
+ }
69
+ const MAX_LATITUDE = 85.05112878;
70
+ function project(lat, lon, zoom, tileSize = 256) {
71
+ const size = tileSize * 2 ** zoom;
72
+ const clamped = Math.max(-MAX_LATITUDE, Math.min(MAX_LATITUDE, lat));
73
+ const sin = Math.sin(clamped * Math.PI / 180);
74
+ return {
75
+ x: (lon + 180) / 360 * size,
76
+ y: (0.5 - Math.log((1 + sin) / (1 - sin)) / (4 * Math.PI)) * size
77
+ };
78
+ }
79
+ function unproject(x, y, zoom, tileSize = 256) {
80
+ const size = tileSize * 2 ** zoom;
81
+ const n = Math.PI - 2 * Math.PI * y / size;
82
+ return {
83
+ lat: 180 / Math.PI * Math.atan(Math.sinh(n)),
84
+ lon: x / size * 360 - 180
85
+ };
86
+ }
87
+ export {
88
+ MAX_LATITUDE,
89
+ OSM_TILES,
90
+ createNominatimProvider,
91
+ emptyAddress,
92
+ formatAddress,
93
+ project,
94
+ tileUrl,
95
+ unproject
96
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  export { default as LayoutCanvas } from './components/LayoutCanvas.vue';
2
+ export { default as LpAddressInput } from './components/LpAddressInput.vue';
3
+ export { default as LpMapPicker } from './components/LpMapPicker.vue';
4
+ export { OSM_TILES, createNominatimProvider, emptyAddress, formatAddress, project, tileUrl, unproject, } from './components/address';
5
+ export type { AddressField, AddressLabels, AddressSuggestion, AddressValue, GeocodeProvider, GeocodeQuery, LatLon, NominatimOptions, TileSource, } from './components/address';
2
6
  export { default as LpAlert } from './components/LpAlert.vue';
3
7
  export { default as LpAppShell } from './components/LpAppShell.vue';
4
8
  export { default as LpAutocomplete } from './components/LpAutocomplete.vue';
@@ -42,7 +46,7 @@ export { default as LpLogViewer } from './components/LpLogViewer.vue';
42
46
  export type { LogLevel, LogLine } from './components/LpLogViewer.vue';
43
47
  export { default as LpModal } from './components/LpModal.vue';
44
48
  export { default as LpNotificationBell } from './components/LpNotificationBell.vue';
45
- export type { NotificationItem } from './components/LpNotificationBell.vue';
49
+ export type { NotificationItem, NotificationLabels, } from './components/LpNotificationBell.vue';
46
50
  export { default as LpNumberField } from './components/LpNumberField.vue';
47
51
  export { default as LpOtpInput } from './components/LpOtpInput.vue';
48
52
  export { default as LpPagination } from './components/LpPagination.vue';