@roxyapi/ui 1.1.1 → 1.1.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/AGENTS.md +5 -5
- package/README.md +3 -3
- package/THEMING.md +3 -3
- package/components-catalog.json +258 -158
- package/dist/cdn/components/almanac-day.js +3 -205
- package/dist/cdn/components/angel-number-card.js +3 -205
- package/dist/cdn/components/angel-number-lookup.js +3 -205
- package/dist/cdn/components/arudha-padas.js +3 -205
- package/dist/cdn/components/ashtakavarga-grid.js +3 -205
- package/dist/cdn/components/aspects-table.js +3 -205
- package/dist/cdn/components/astrocartography-map.js +3 -205
- package/dist/cdn/components/bazi-chart.js +3 -205
- package/dist/cdn/components/bhav-chalit-table.js +2 -204
- package/dist/cdn/components/bhava-bala-table.js +3 -205
- package/dist/cdn/components/biorhythm-chart.js +3 -205
- package/dist/cdn/components/bodygraph.js +7 -209
- package/dist/cdn/components/chara-karakas.js +3 -205
- package/dist/cdn/components/choghadiya-grid.js +3 -205
- package/dist/cdn/components/compatibility-card.js +2 -204
- package/dist/cdn/components/compound-number.js +3 -205
- package/dist/cdn/components/crystal-card.js +3 -205
- package/dist/cdn/components/crystal-grid.js +3 -205
- package/dist/cdn/components/dasha-timeline.js +3 -205
- package/dist/cdn/components/data.js +3 -205
- package/dist/cdn/components/divisional-chart.js +13 -215
- package/dist/cdn/components/dosha-card.js +3 -205
- package/dist/cdn/components/dosha-constitution.js +3 -205
- package/dist/cdn/components/dream-card.js +3 -205
- package/dist/cdn/components/dream-search.js +3 -205
- package/dist/cdn/components/endpoint-form.js +3 -205
- package/dist/cdn/components/ephemeris-table.js +2 -204
- package/dist/cdn/components/fixed-stars.js +2 -204
- package/dist/cdn/components/flying-star-chart.js +2 -204
- package/dist/cdn/components/forecast-digest.js +3 -205
- package/dist/cdn/components/forecast-timeline.js +3 -205
- package/dist/cdn/components/gematria.js +3 -205
- package/dist/cdn/components/gochara-table.js +3 -205
- package/dist/cdn/components/guna-milan.js +3 -205
- package/dist/cdn/components/hd-connection.js +5 -207
- package/dist/cdn/components/hd-penta.js +5 -207
- package/dist/cdn/components/hd-type-card.js +3 -205
- package/dist/cdn/components/hd-variables.js +3 -205
- package/dist/cdn/components/heliacal-table.js +3 -205
- package/dist/cdn/components/hexagram.js +3 -205
- package/dist/cdn/components/hora-table.js +3 -205
- package/dist/cdn/components/horoscope-card.js +3 -205
- package/dist/cdn/components/kp-chart.js +3 -205
- package/dist/cdn/components/kp-finance-card.js +3 -205
- package/dist/cdn/components/kp-planets-table.js +3 -205
- package/dist/cdn/components/kp-ruling-planets.js +3 -205
- package/dist/cdn/components/kua-card.js +3 -205
- package/dist/cdn/components/local-space-compass.js +8 -210
- package/dist/cdn/components/location-search.js +3 -205
- package/dist/cdn/components/luck-pillars.js +3 -205
- package/dist/cdn/components/mayan-day-sign.js +3 -205
- package/dist/cdn/components/moon-phase.js +3 -205
- package/dist/cdn/components/nakshatra-card.js +3 -205
- package/dist/cdn/components/natal-chart.js +6 -208
- package/dist/cdn/components/numerology-card.js +3 -205
- package/dist/cdn/components/panchang-table.js +3 -205
- package/dist/cdn/components/positions-table.js +3 -205
- package/dist/cdn/components/profection-card.js +3 -205
- package/dist/cdn/components/reference-card.js +3 -205
- package/dist/cdn/components/relocation-wheel.js +6 -208
- package/dist/cdn/components/shadbala-table.js +3 -205
- package/dist/cdn/components/synastry-chart.js +7 -209
- package/dist/cdn/components/tarot-card.js +3 -205
- package/dist/cdn/components/tarot-catalog.js +3 -205
- package/dist/cdn/components/tarot-spread.js +3 -205
- package/dist/cdn/components/transit-wheel.js +8 -210
- package/dist/cdn/components/transits-table.js +3 -205
- package/dist/cdn/components/upagraha-table.js +2 -204
- package/dist/cdn/components/vastu-mandala.js +4 -206
- package/dist/cdn/components/vedic-aspects.js +2 -204
- package/dist/cdn/components/vedic-daily.js +3 -205
- package/dist/cdn/components/vedic-kundli.js +10 -212
- package/dist/cdn/components/vedic-planets-table.js +3 -205
- package/dist/cdn/components/western-planets-table.js +2 -204
- package/dist/cdn/components/yoga-list.js +3 -205
- package/dist/cdn/components/zodiac-card.js +2 -204
- package/dist/cdn/locales/de.js +1 -1
- package/dist/cdn/roxy-ui.js +49 -251
- package/dist/components/almanac-day.js +1 -203
- package/dist/components/angel-number-card.js +1 -203
- package/dist/components/angel-number-lookup.js +1 -203
- package/dist/components/arudha-padas.js +1 -203
- package/dist/components/ashtakavarga-grid.js +1 -203
- package/dist/components/aspects-table.js +1 -203
- package/dist/components/astrocartography-map.js +6 -208
- package/dist/components/bazi-chart.js +1 -203
- package/dist/components/bhav-chalit-table.js +1 -203
- package/dist/components/bhava-bala-table.js +1 -203
- package/dist/components/biorhythm-chart.js +1 -203
- package/dist/components/bodygraph.js +3 -205
- package/dist/components/chara-karakas.js +1 -203
- package/dist/components/choghadiya-grid.js +1 -203
- package/dist/components/compatibility-card.js +1 -203
- package/dist/components/compound-number.js +1 -203
- package/dist/components/crystal-card.js +1 -203
- package/dist/components/crystal-grid.js +1 -203
- package/dist/components/dasha-timeline.js +1 -203
- package/dist/components/data.js +1 -203
- package/dist/components/divisional-chart.js +45 -247
- package/dist/components/dosha-card.js +1 -203
- package/dist/components/dosha-constitution.js +1 -203
- package/dist/components/dream-card.js +1 -203
- package/dist/components/dream-search.js +1 -203
- package/dist/components/endpoint-form.js +1 -203
- package/dist/components/ephemeris-table.js +1 -203
- package/dist/components/fixed-stars.js +1 -203
- package/dist/components/flying-star-chart.js +1 -203
- package/dist/components/forecast-digest.js +1 -203
- package/dist/components/forecast-timeline.js +1 -203
- package/dist/components/gematria.js +1 -203
- package/dist/components/gochara-table.js +1 -203
- package/dist/components/guna-milan.js +1 -203
- package/dist/components/hd-connection.js +3 -205
- package/dist/components/hd-penta.js +5 -207
- package/dist/components/hd-type-card.js +1 -203
- package/dist/components/hd-variables.js +1 -203
- package/dist/components/heliacal-table.js +1 -203
- package/dist/components/hexagram.d.ts +1 -1
- package/dist/components/hexagram.js +1 -203
- package/dist/components/hora-table.js +1 -203
- package/dist/components/horoscope-card.js +1 -203
- package/dist/components/kp-chart.js +1 -203
- package/dist/components/kp-finance-card.js +1 -203
- package/dist/components/kp-planets-table.js +1 -203
- package/dist/components/kp-ruling-planets.js +1 -203
- package/dist/components/kua-card.js +1 -203
- package/dist/components/local-space-compass.js +4 -206
- package/dist/components/location-search.js +1 -203
- package/dist/components/luck-pillars.js +1 -203
- package/dist/components/mayan-day-sign.js +1 -203
- package/dist/components/moon-phase.js +1 -203
- package/dist/components/nakshatra-card.js +1 -203
- package/dist/components/natal-chart.d.ts +1 -1
- package/dist/components/natal-chart.js +5 -207
- package/dist/components/numerology-card.js +1 -203
- package/dist/components/panchang-table.js +1 -203
- package/dist/components/positions-table.js +1 -203
- package/dist/components/profection-card.js +1 -203
- package/dist/components/reference-card.js +1 -203
- package/dist/components/relocation-wheel.js +3 -205
- package/dist/components/shadbala-table.js +1 -203
- package/dist/components/synastry-chart.js +6 -208
- package/dist/components/tarot-card.js +1 -203
- package/dist/components/tarot-catalog.js +1 -203
- package/dist/components/tarot-spread.js +1 -203
- package/dist/components/transit-wheel.js +8 -210
- package/dist/components/transits-table.js +1 -203
- package/dist/components/upagraha-table.js +1 -203
- package/dist/components/vastu-mandala.js +6 -208
- package/dist/components/vedic-aspects.js +1 -203
- package/dist/components/vedic-daily.js +1 -203
- package/dist/components/vedic-kundli.js +15 -217
- package/dist/components/vedic-planets-table.js +1 -203
- package/dist/components/western-planets-table.js +1 -203
- package/dist/components/yoga-list.js +1 -203
- package/dist/components/zodiac-card.js +1 -203
- package/dist/forms.json +1 -1
- package/dist/index.cjs +49 -251
- package/dist/index.js +50 -252
- package/dist/locales/de.js +1 -1
- package/dist/schemas/post--astrology-lilith.json +1 -1
- package/dist/schemas/post--astrology-progressions.json +1 -1
- package/dist/schemas/post--kabbalah-birth-profile.json +1 -1
- package/dist/schemas/post--numerology-chart.json +1 -1
- package/dist/schemas/post--vedic-astrology-daily.json +1 -1
- package/dist/schemas/post--vedic-astrology-dasha-current.json +1 -1
- package/dist/schemas/post--vedic-astrology-dasha-major.json +1 -1
- package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha-antardasha-pratyantardasha-sookshma.json +1 -1
- package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha-antardasha-pratyantardasha.json +1 -1
- package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha-antardasha.json +1 -1
- package/dist/schemas/post--vedic-astrology-dasha-sub-mahadasha.json +1 -1
- package/dist/schemas/post--vedic-astrology-kp-chart.json +1 -1
- package/dist/schemas/post--vedic-astrology-kp-cusps.json +1 -1
- package/dist/schemas/post--vedic-astrology-kp-daily-finance.json +1 -1
- package/dist/schemas/post--vedic-astrology-kp-horary.json +1 -1
- package/dist/schemas/post--vedic-astrology-kp-planets.json +1 -1
- package/dist/schemas/post--vedic-astrology-kp-ruling-planets-interval.json +1 -1
- package/dist/schemas/post--vedic-astrology-kp-ruling-planets.json +1 -1
- package/dist/schemas/post--vedic-astrology-transit.json +1 -1
- package/dist/styles/palettes.d.ts +4 -0
- package/dist/styles/themes/celeste.css +1 -115
- package/dist/styles/themes/eucalyptus.css +1 -121
- package/dist/styles/themes/kiln.css +1 -121
- package/dist/styles/themes/moonlit.css +1 -121
- package/dist/styles/themes/practitioner.css +1 -170
- package/dist/styles/tokens-css.d.ts +1 -1
- package/dist/styles/tokens.css +1 -202
- package/dist/types/types.gen.d.ts +48 -36
- package/dist/utils/string.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,203 +1 @@
|
|
|
1
|
-
var j=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var i=(t,r,e,o)=>{for(var s=o>1?void 0:o?D(r,e):r,a=t.length-1,l;a>=0;a--)(l=t[a])&&(s=(o?l(r,e,s):l(s))||s);return o&&s&&j(r,e,s),s};import{css as Q,html as c,nothing as b}from"lit";import{property as d,state as u}from"lit/decorators.js";import{LitElement as M}from"lit";var v=`/**
|
|
2
|
-
* Roxy UI design tokens: every colour, size, space, radius, font and duration a component reads.
|
|
3
|
-
*
|
|
4
|
-
* Two tiers. BASES are the few values a host tunes: fonts, base text size and its scale ratio, the
|
|
5
|
-
* space unit, the base radius, motion, and the colour bases (bg, fg, accent and the four status
|
|
6
|
-
* colours). Every other token DERIVES from them with calc() or color-mix(), so dark mode reassigns
|
|
7
|
-
* the colour bases only and one font token restyles every heading. A host may still set any
|
|
8
|
-
* derived token directly, and its value wins.
|
|
9
|
-
*
|
|
10
|
-
* Delivery: a global light-DOM stylesheet (linked, or injected by the CDN bundle). Custom properties
|
|
11
|
-
* inherit through the shadow boundary, so a token set on any light-DOM ancestor reaches every
|
|
12
|
-
* component. The :host selectors apply only if this sheet is adopted into a shadow root.
|
|
13
|
-
*
|
|
14
|
-
* Light is the default. Dark applies under prefers-color-scheme: dark, or [data-theme="dark"] or
|
|
15
|
-
* .dark on the element or any ancestor; [data-theme="light"] or .light opts back into light. An
|
|
16
|
-
* explicit choice wins over the OS because those blocks come later in source order.
|
|
17
|
-
*
|
|
18
|
-
* A derivation is computed where it is declared, so the derived block also matches every theme
|
|
19
|
-
* trigger: a base reassigned on :root or on an element carrying data-theme, .light or .dark
|
|
20
|
-
* re-derives everything below it.
|
|
21
|
-
*
|
|
22
|
-
* Font: --roxy-font-sans is unset by default, so every component inherits the host page font; any
|
|
23
|
-
* value set by the host or a preset replaces it, and --roxy-font-display follows it until set.
|
|
24
|
-
*
|
|
25
|
-
* Motion: --roxy-motion-duration defaults to 200ms and prefers-reduced-motion forces 0ms.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/*
|
|
29
|
-
* Two mechanisms keep the host page in charge of every token, and both are load bearing.
|
|
30
|
-
*
|
|
31
|
-
* Every rule sits in the roxy.tokens cascade layer, and an unlayered declaration beats a layered
|
|
32
|
-
* one at ANY specificity, so a plain \`:root { --roxy-accent: #8b5cf6 }\` on the host page wins, and
|
|
33
|
-
* so does the same line inside a layer of its own, because this statement registers ours first
|
|
34
|
-
* and the CDN bundle injects this sheet at the top of <head>. A host that links this file after its
|
|
35
|
-
* own CSS orders the layers itself: \`@layer roxy, base, components, utilities;\` before either sheet.
|
|
36
|
-
*
|
|
37
|
-
* Every selector is ALSO wrapped in :where(), which has ZERO specificity, so a host declaration
|
|
38
|
-
* still wins wherever a layer cannot decide it, under every dark signal alike.
|
|
39
|
-
*
|
|
40
|
-
* The theme presets in styles/themes/*.css write into roxy.theme; both files declare this order,
|
|
41
|
-
* so either one loading alone still ranks a preset above these defaults.
|
|
42
|
-
*/
|
|
43
|
-
@layer roxy.tokens, roxy.theme;
|
|
44
|
-
|
|
45
|
-
@layer roxy.tokens {
|
|
46
|
-
/* Bases, light. Also the mode-specific derivations: accent ink and status inks mix toward black. */
|
|
47
|
-
:where(:root, :host) {
|
|
48
|
-
/* A real inherited property: native controls, popups and scrollbars follow it. */
|
|
49
|
-
color-scheme: light;
|
|
50
|
-
|
|
51
|
-
--roxy-bg: #ffffff;
|
|
52
|
-
--roxy-fg: #0a0a0a;
|
|
53
|
-
--roxy-accent: #4a6297;
|
|
54
|
-
--roxy-success: #16a34a;
|
|
55
|
-
--roxy-warning: #ea580c;
|
|
56
|
-
--roxy-danger: #dc2626;
|
|
57
|
-
--roxy-info: #0284c7;
|
|
58
|
-
|
|
59
|
-
/* Accent and status inks: 70 percent toward black reads at AA on the card and on a tint of the base. */
|
|
60
|
-
--roxy-accent-ink: color-mix(in oklab, var(--roxy-accent) 70%, black);
|
|
61
|
-
--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, black);
|
|
62
|
-
--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, black);
|
|
63
|
-
--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, black);
|
|
64
|
-
--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, black);
|
|
65
|
-
|
|
66
|
-
/* Unset on purpose: a component inherits the host page font until a host or preset sets one. */
|
|
67
|
-
--roxy-font-sans: initial;
|
|
68
|
-
--roxy-font-mono:
|
|
69
|
-
ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas,
|
|
70
|
-
"Liberation Mono", monospace;
|
|
71
|
-
|
|
72
|
-
--roxy-text-base: 1rem;
|
|
73
|
-
--roxy-text-scale: 1.15;
|
|
74
|
-
--roxy-weight-normal: 400;
|
|
75
|
-
--roxy-weight-bold: 600;
|
|
76
|
-
--roxy-leading-tight: 1.25;
|
|
77
|
-
--roxy-leading-normal: 1.5;
|
|
78
|
-
--roxy-tracking-tight: -0.01em;
|
|
79
|
-
--roxy-tracking-normal: 0em;
|
|
80
|
-
|
|
81
|
-
--roxy-space-unit: 0.25rem;
|
|
82
|
-
--roxy-radius: 6px;
|
|
83
|
-
|
|
84
|
-
--roxy-motion-duration: 200ms;
|
|
85
|
-
--roxy-motion-easing: cubic-bezier(0.4, 0, 0.2, 1);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/* Derived roles, identical in every mode, restated on every theme trigger so they follow its bases. */
|
|
89
|
-
:where(:root, :host, [data-theme], .light, .dark) {
|
|
90
|
-
/* Flat: the card is the page colour, separated by a hairline. */
|
|
91
|
-
--roxy-surface: var(--roxy-bg);
|
|
92
|
-
--roxy-primary: var(--roxy-fg);
|
|
93
|
-
--roxy-secondary: color-mix(in oklab, var(--roxy-fg) 78%, var(--roxy-bg));
|
|
94
|
-
--roxy-muted: color-mix(in oklab, var(--roxy-fg) 60%, var(--roxy-bg));
|
|
95
|
-
--roxy-border: color-mix(in oklab, var(--roxy-fg) 14%, var(--roxy-bg));
|
|
96
|
-
--roxy-ring: color-mix(in srgb, var(--roxy-accent) 40%, transparent);
|
|
97
|
-
--roxy-heat: var(--roxy-danger);
|
|
98
|
-
|
|
99
|
-
--roxy-font-display: var(--roxy-font-sans);
|
|
100
|
-
|
|
101
|
-
--roxy-text-sm: calc(var(--roxy-text-base) / var(--roxy-text-scale));
|
|
102
|
-
--roxy-text-xs: calc(var(--roxy-text-sm) / var(--roxy-text-scale));
|
|
103
|
-
--roxy-text-lg: calc(var(--roxy-text-base) * var(--roxy-text-scale));
|
|
104
|
-
--roxy-text-xl: calc(
|
|
105
|
-
var(--roxy-text-lg) *
|
|
106
|
-
var(--roxy-text-scale) *
|
|
107
|
-
var(--roxy-text-scale)
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
--roxy-space-xs: var(--roxy-space-unit);
|
|
111
|
-
--roxy-space-sm: calc(var(--roxy-space-unit) * 2);
|
|
112
|
-
--roxy-space-md: calc(var(--roxy-space-unit) * 4);
|
|
113
|
-
--roxy-space-lg: calc(var(--roxy-space-unit) * 6);
|
|
114
|
-
--roxy-space-xl: calc(var(--roxy-space-unit) * 10);
|
|
115
|
-
--roxy-line-thick: calc(var(--roxy-space-unit) / 2);
|
|
116
|
-
--roxy-touch: calc(var(--roxy-space-unit) * 11);
|
|
117
|
-
|
|
118
|
-
--roxy-radius-sm: calc(var(--roxy-radius) / 2);
|
|
119
|
-
--roxy-radius-md: var(--roxy-radius);
|
|
120
|
-
--roxy-radius-lg: calc(var(--roxy-radius) * 5 / 3);
|
|
121
|
-
--roxy-radius-full: 9999px;
|
|
122
|
-
|
|
123
|
-
/* Flat surfaces cast nothing; only a floating layer (a popup, an enlarged chart) lifts. */
|
|
124
|
-
--roxy-shadow-sm: none;
|
|
125
|
-
--roxy-shadow-md: 0 4px 12px color-mix(in srgb, black 10%, transparent);
|
|
126
|
-
--roxy-shadow-lg: 0 12px 32px color-mix(in srgb, black 18%, transparent);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/* Bases, dark, by system preference. Inks mix toward white so they read on a dark card. */
|
|
130
|
-
@media (prefers-color-scheme: dark) {
|
|
131
|
-
:where(:root, :host) {
|
|
132
|
-
color-scheme: dark;
|
|
133
|
-
--roxy-bg: #0a0a0a;
|
|
134
|
-
--roxy-fg: #fafafa;
|
|
135
|
-
--roxy-accent: #92aade;
|
|
136
|
-
--roxy-success: #22c55e;
|
|
137
|
-
--roxy-warning: #fb923c;
|
|
138
|
-
--roxy-danger: #ef4444;
|
|
139
|
-
--roxy-info: #38bdf8;
|
|
140
|
-
|
|
141
|
-
--roxy-accent-ink: var(--roxy-accent);
|
|
142
|
-
--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, white);
|
|
143
|
-
--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, white);
|
|
144
|
-
--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, white);
|
|
145
|
-
--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, white);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/* Explicit light: beats the OS dark block when the host chooses light. */
|
|
150
|
-
:where(
|
|
151
|
-
:root[data-theme="light"],
|
|
152
|
-
[data-theme="light"],
|
|
153
|
-
:root.light,
|
|
154
|
-
.light,
|
|
155
|
-
:host([data-theme="light"])
|
|
156
|
-
) {
|
|
157
|
-
color-scheme: light;
|
|
158
|
-
--roxy-bg: #ffffff;
|
|
159
|
-
--roxy-fg: #0a0a0a;
|
|
160
|
-
--roxy-accent: #4a6297;
|
|
161
|
-
--roxy-success: #16a34a;
|
|
162
|
-
--roxy-warning: #ea580c;
|
|
163
|
-
--roxy-danger: #dc2626;
|
|
164
|
-
--roxy-info: #0284c7;
|
|
165
|
-
|
|
166
|
-
--roxy-accent-ink: color-mix(in oklab, var(--roxy-accent) 70%, black);
|
|
167
|
-
--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, black);
|
|
168
|
-
--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, black);
|
|
169
|
-
--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, black);
|
|
170
|
-
--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, black);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/* Explicit dark: a .dark class or data-theme="dark" on any ancestor themes every component below it. */
|
|
174
|
-
:where(
|
|
175
|
-
:root[data-theme="dark"],
|
|
176
|
-
[data-theme="dark"],
|
|
177
|
-
:root.dark,
|
|
178
|
-
.dark,
|
|
179
|
-
:host([data-theme="dark"])
|
|
180
|
-
) {
|
|
181
|
-
color-scheme: dark;
|
|
182
|
-
--roxy-bg: #0a0a0a;
|
|
183
|
-
--roxy-fg: #fafafa;
|
|
184
|
-
--roxy-accent: #92aade;
|
|
185
|
-
--roxy-success: #22c55e;
|
|
186
|
-
--roxy-warning: #fb923c;
|
|
187
|
-
--roxy-danger: #ef4444;
|
|
188
|
-
--roxy-info: #38bdf8;
|
|
189
|
-
|
|
190
|
-
--roxy-accent-ink: var(--roxy-accent);
|
|
191
|
-
--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, white);
|
|
192
|
-
--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, white);
|
|
193
|
-
--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, white);
|
|
194
|
-
--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, white);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
@media (prefers-reduced-motion: reduce) {
|
|
198
|
-
:where(:root, :host) {
|
|
199
|
-
--roxy-motion-duration: 0ms;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
`;var w="roxy-ui-tokens";function k(){if(typeof document>"u")return null;let t=document.getElementById(w);if(t)return t;let r=document.createElement("style");return r.id=w,r.textContent=v,document.head.prepend(r),r}function R(t){if(t.lang)return t.lang;if(typeof document>"u")return;let r=t.closest?.("[lang]")?.getAttribute("lang");return r||document.documentElement.lang||void 0}function C(t){return t.toLowerCase().replace(/[\s_-]+/g," ").trim()}var E="__ROXY_UI_I18N__";function A(){let t=globalThis,r=t[E];if(r)return r;let e={catalogs:{},fieldLabels:{},requested:new Set,listeners:new Set};return t[E]=e,e}function H(t,r){return r?t.replace(/\{\{(\w+)\}\}/g,(e,o)=>o in r?String(r[o]??""):e):t}function S(t,r,e){return H(Y(t,r)??r,e)}function Y(t,r){if(!t)return;let{catalogs:e}=A(),o=t.toLowerCase();return(e[o]??e[o.split("-")[0]])?.[C(r)]}function L(t){let{listeners:r}=A();return r.add(t),()=>{r.delete(t)}}var h=class{constructor(r){this.host=r,r.addController(this)}hostConnected(){this.unsubscribe=L(()=>this.host.requestUpdate())}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0}};var y=class extends M{constructor(){super();this.translator=(e,o)=>this.t(e,o);new h(this)}connectedCallback(){super.connectedCallback(),k()}t(e,o){return S(this.effectiveLang(),e,o)}effectiveLang(){return R(this)}};import{css as N}from"lit";import{css as q}from"lit";var T=q`:where([part~=card]){background:var(--roxy-surface);color:var(--roxy-fg);border:1px solid var(--roxy-border);border-radius:var(--roxy-radius-lg);box-shadow:var(--roxy-shadow-sm)}:where([part~=card] [part~=card],[part~=card] [part~=reading],[part~=card] .roxy-card){border:0;border-block-start:1px solid var(--roxy-border);box-shadow:none;background:0 0;border-radius:0;padding-inline:0}:host([bare]) [part~=card]{box-shadow:none;background:0 0;border:0;border-radius:0;padding:0}:where(h1,h2){color:var(--roxy-fg);font-size:var(--roxy-text-lg);font-weight:var(--roxy-weight-bold);line-height:var(--roxy-leading-tight);letter-spacing:var(--roxy-tracking-tight);text-wrap:balance}:where(h3,h4,h5,h6){color:var(--roxy-fg);font-size:var(--roxy-text-base);font-weight:var(--roxy-weight-bold);line-height:var(--roxy-leading-tight);letter-spacing:var(--roxy-tracking-normal);text-transform:none}:where(.roxy-label,th,dt){color:var(--roxy-muted);font-size:var(--roxy-text-sm);font-weight:var(--roxy-weight-normal);letter-spacing:var(--roxy-tracking-normal);text-transform:none}:where(.roxy-chips){gap:var(--roxy-space-xs);flex-wrap:wrap;margin:0;padding:0;list-style:none;display:flex}:where(.roxy-chip,.roxy-chips>li){align-items:center;gap:var(--roxy-space-xs);padding:calc(var(--roxy-space-unit) / 2) var(--roxy-space-sm);border:1px solid var(--roxy-border);border-radius:var(--roxy-radius-sm);color:var(--roxy-secondary);font-size:var(--roxy-text-xs);line-height:var(--roxy-leading-tight);overflow-wrap:anywhere;background:0 0;max-inline-size:100%;display:inline-flex}:where(.roxy-chip[data-tone=success],.roxy-chips>li[data-tone=success]){color:var(--roxy-success-fg)}:where(.roxy-chip[data-tone=warning],.roxy-chips>li[data-tone=warning]){color:var(--roxy-warning-fg)}:where(.roxy-chip[data-tone=danger],.roxy-chips>li[data-tone=danger]){color:var(--roxy-danger-fg)}:where(.roxy-chip[data-tone=info],.roxy-chips>li[data-tone=info]){color:var(--roxy-info-fg)}:where(table){border-collapse:collapse;font-size:var(--roxy-text-sm);font-variant-numeric:tabular-nums}:where(th,td){padding:var(--roxy-space-xs) var(--roxy-space-sm);border-block-end:1px solid var(--roxy-border);text-align:start;vertical-align:top}:where(summary){cursor:pointer}:where(a,button,summary,input,select,textarea,[tabindex]):focus-visible{outline:var(--roxy-line-thick) solid var(--roxy-ring);outline-offset:var(--roxy-line-thick)}:where(summary:focus-visible){border-radius:var(--roxy-radius-sm)}:where(input,select,textarea,button){font:inherit}:where(input:not([type=checkbox],[type=radio],[type=range]),select,textarea){padding:var(--roxy-space-xs) var(--roxy-space-sm);background:var(--roxy-bg);color:var(--roxy-fg);border:1px solid var(--roxy-border);border-radius:var(--roxy-radius-md)}`;var B=N`:host{--roxy-label-col:minmax(0, 25%);--_mask:var(--roxy-surface);font-family:var(--roxy-font-sans);color:var(--roxy-fg);font-size:var(--roxy-text-base);line-height:var(--roxy-leading-normal);animation:roxy-fade-in var(--roxy-motion-duration) var(--roxy-motion-easing) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--_mask:var(--roxy-bg)}:host([hidden]){display:none}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display)}@keyframes roxy-fade-in{0%{transform:translateY(calc(var(--roxy-space-unit) / 2))}to{transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border) 0%, color-mix(in srgb, var(--roxy-border) 60%, transparent) 50%, var(--roxy-border) 100%);border-radius:var(--roxy-radius-md);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg);color:var(--roxy-muted);text-align:center;font-size:var(--roxy-text-sm)}.roxy-error{gap:var(--roxy-space-sm);padding:var(--roxy-space-lg);background:var(--roxy-surface);border:1px solid var(--roxy-danger);border-radius:var(--roxy-radius-md);color:var(--roxy-danger-fg);font-size:var(--roxy-text-sm);justify-items:start;display:grid}:host(:focus-within) .roxy-card{outline:var(--roxy-line-thick) solid var(--roxy-ring);outline-offset:var(--roxy-line-thick)}.roxy-attribution{margin-top:var(--roxy-space-sm);font-size:var(--roxy-text-xs);color:var(--roxy-muted);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink);text-decoration:underline}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs) var(--roxy-space-md);border:1px solid var(--roxy-border);border-radius:var(--roxy-radius-md);color:var(--roxy-fg);font-family:inherit;font-size:var(--roxy-text-sm);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent);color:var(--roxy-accent-ink)}.roxy-edit:disabled{cursor:progress;color:var(--roxy-muted)}roxy-endpoint-form+*{margin-top:var(--roxy-space-md)}.roxy-more{justify-items:center;gap:var(--roxy-space-sm);margin-top:var(--roxy-space-md);display:grid}.roxy-more .roxy-edit{min-height:var(--roxy-touch)}:host{font-variant-emoji:text}`,O=[B,T];import{css as G}from"lit";var $=G`.spinner{inset-inline-end:calc(var(--roxy-space-unit) * 3);border:var(--roxy-line-thick) solid var(--roxy-muted);border-radius:var(--roxy-radius-full);border-top-color:#0000;block-size:.6lh;inline-size:.6lh;animation:.7s linear infinite roxy-spin;position:absolute;top:50%;transform:translateY(-50%)}@keyframes roxy-spin{to{transform:translateY(-50%)rotate(360deg)}}@media (prefers-reduced-motion:reduce){.spinner{animation:none}}.results{z-index:50;top:calc(100% + var(--roxy-space-xs));padding:var(--roxy-space-xs);background:var(--roxy-bg);border:1px solid var(--roxy-border);border-radius:var(--roxy-radius-md);box-shadow:var(--roxy-shadow-md);max-block-size:15lh;animation:roxy-fade-in var(--roxy-motion-duration) var(--roxy-motion-easing);margin:0;list-style:none;position:absolute;left:0;right:0;overflow-y:auto}.option{align-items:center;gap:var(--roxy-space-sm);inline-size:100%;min-block-size:var(--roxy-touch);padding:var(--roxy-space-sm) var(--roxy-space-md);border-radius:var(--roxy-radius-sm);text-align:start;font-size:var(--roxy-text-sm);color:var(--roxy-fg);cursor:pointer;transition:background-color var(--roxy-motion-duration);background:0 0;border:0;display:flex}.option:hover,.option[aria-selected=true]{background:color-mix(in srgb, var(--roxy-accent) 10%, transparent)}.empty{padding:var(--roxy-space-md);color:var(--roxy-muted);font-size:var(--roxy-text-sm)}`;function K(t,r){let e,o=((...s)=>{e&&clearTimeout(e),e=setTimeout(()=>{e=void 0,t(...s)},r)});return o.cancel=()=>{e&&(clearTimeout(e),e=void 0)},o}var U=t=>r=>{customElements.get(t)||customElements.define(t,r)};var X="pk_live_YOUR_KEY",_={secret:{reason:"possible-secret-key",message:"Client-side components accept a pk_ publishable key only. Use a publishable key with an origin allowlist, or render server-side."},sample:{reason:"sample-key",message:"Replace the sample key with your own publishable key from your RoxyAPI account."}};function p(t){if(t)return t===X?_.sample:t.startsWith("pk_")?void 0:_.secret}function f(t,r,e={}){e.warn&&console.warn(r.message),t.dispatchEvent(new CustomEvent("roxy-validation-error",{detail:{reason:r.reason,message:r.message},bubbles:!0,composed:!0}))}var m="https://roxyapi.com/api/v2";async function z(t){return(await F(t)).message}async function F(t){try{let r=await t.json();if(r?.error){let e=r.code==="validation_error"&&Array.isArray(r.issues)?r.issues.filter(o=>typeof o.path=="string"&&typeof o.message=="string").map(o=>({path:o.path,message:o.message})):null;return{message:r.error,issues:e?.length?e:null,worded:!0}}}catch{}return{message:`Request failed (${t.status})`,issues:null,worded:!1}}var I={fromAttribute:t=>{if(t!=null){try{let r=JSON.parse(t);if(r&&typeof r=="object"&&!Array.isArray(r))return r}catch{}console.warn("[roxy-ui] submit-context must be a JSON object; sending the request without it.")}}},x=class extends Error{constructor(e,o=null,s=!0){super(e);this.issues=o;this.worded=s}};function V(t){return t.submitUrl?void 0:p(t.publishableKey)}async function P(t,r,e){let o=V(t);if(o)throw new x(o.message);let s=t.submitUrl?await fetch(t.submitUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:J(r,t.submitContext),signal:e}):await Z(t,r,e);if(!s.ok){let a=await F(s);throw new x(a.message,a.issues,a.worded)}return await s.json()}function J(t,r){return JSON.stringify(r?{...t,context:r}:t)}function Z(t,r,e){let o=new URL(`${t.baseUrl??m}${r.path}`,document.baseURI);for(let[a,l]of Object.entries(r.query??{}))l!=null&&o.searchParams.set(a,String(l));let s={Accept:"application/json"};return t.publishableKey&&(s["X-API-Key"]=t.publishableKey),r.body!=null&&(s["Content-Type"]="application/json"),fetch(o,{method:r.method??"GET",headers:s,body:r.body!=null?JSON.stringify(r.body):void 0,signal:e})}var n=class extends y{constructor(){super(...arguments);this.placeholder="Search city";this.defaultValue="";this.query="";this.results=[];this.isOpen=!1;this.isLoading=!1;this.highlight=-1;this.error=null;this.debouncedFetch=K(e=>{this.fetchResults(e)},300);this.onInput=e=>{let o=e.target.value;if(this.query=o,o.length<2){this.results=[],this.isOpen=!1,this.highlight=-1,this.error=null;return}this.debouncedFetch(o)};this.onKeyDown=e=>{if(!this.isOpen||this.results.length===0){e.key==="ArrowDown"&&this.query.length>=2&&(this.fetchResults(this.query),e.preventDefault());return}if(e.key==="ArrowDown")e.preventDefault(),this.highlight=(this.highlight+1)%this.results.length;else if(e.key==="ArrowUp")e.preventDefault(),this.highlight=(this.highlight-1+this.results.length)%this.results.length;else if(e.key==="Enter"){e.preventDefault();let o=this.results[this.highlight]??this.results[0];o&&this.select(o)}else e.key==="Escape"&&(this.isOpen=!1)}}connectedCallback(){super.connectedCallback(),this.query=this.defaultValue,this.clickOutsideHandler=e=>{e.composedPath().includes(this)||(this.isOpen=!1)},document.addEventListener("mousedown",this.clickOutsideHandler)}willUpdate(e){if(e.has("publishableKey")||e.has("apiKey")){let o=p(this.publishableKey??this.apiKey);o&&!this.refusal&&f(this,o,{warn:!0}),this.refusal=o}}disconnectedCallback(){super.disconnectedCallback(),this.clickOutsideHandler&&document.removeEventListener("mousedown",this.clickOutsideHandler),this.debouncedFetch.cancel(),this.abortController&&(this.abortController.abort(),this.abortController=void 0)}async fetchResults(e){if(this.refusal)return;this.abortController&&this.abortController.abort();let o=new AbortController;this.abortController=o,this.isLoading=!0;try{let s=await this.search(e,o.signal);if(o.signal.aborted)return;this.error=null,this.results=s.cities??[],this.isOpen=!0,this.highlight=this.results.length>0?0:-1}catch(s){if(s?.name==="AbortError")return;this.results=[],this.isOpen=!1,this.highlight=-1,this.error=s instanceof Error?s.message:String(s)}finally{this.abortController===o&&(this.abortController=void 0),o.signal.aborted||(this.isLoading=!1)}}async search(e,o){if(!this.endpoint&&this.submitUrl)return P({submitUrl:this.submitUrl,submitContext:this.submitContext},{path:"/location/search",method:"GET",query:{q:e,limit:8}},o);let s=new URL(this.endpoint||`${m}/location/search`,document.baseURI);s.searchParams.set("q",e),s.searchParams.set("limit","8");let a={Accept:"application/json"};this.apiKey&&this.publishableKey&&console.warn("[roxy-location-search] both api-key and publishable-key set; using publishable-key. Remove api-key from your widget markup.");let l=this.publishableKey??this.apiKey;l&&(a["X-API-Key"]=l);let g=await fetch(s,{headers:a,signal:o});if(!g.ok)throw new Error(await z(g));return await g.json()}select(e){this.query=`${e.city}${e.province?`, ${e.province}`:""}, ${e.country}`,this.isOpen=!1,this.results=[],this.dispatchEvent(new CustomEvent("roxy-location-select",{detail:e,bubbles:!0,composed:!0}))}render(){return this.refusal?c`<div class="roxy-error" role="alert">${this.t(this.refusal.message)}</div>`:c`<div class="field"><input part="input" type="text" role="combobox" aria-expanded="${this.isOpen?"true":"false"}" aria-controls="roxy-location-listbox" aria-activedescendant="${this.isOpen&&this.highlight>=0?`roxy-location-option-${this.highlight}`:""}" aria-autocomplete="list" autocomplete="off" placeholder="${this.t(this.placeholder)}" .value="${this.query}" @input="${this.onInput}" @keydown="${this.onKeyDown}" @focus="${()=>{this.results.length>0&&(this.isOpen=!0)}}"> ${this.isLoading?c`<span class="spinner" role="status" aria-label="${this.t("Loading")}"></span>`:b} ${this.isOpen?c`<ul id="roxy-location-listbox" part="results" class="results" role="listbox">${this.results.length===0?c`<li class="empty" role="status">${this.t("No cities found")}</li>`:this.results.map((e,o)=>c`<li role="presentation"><button type="button" part="option" class="option" role="option" id="${`roxy-location-option-${o}`}" aria-selected="${this.highlight===o?"true":"false"}" @click="${()=>this.select(e)}" @mouseenter="${()=>{this.highlight=o}}"><span class="city">${e.city}</span> <span class="where">${e.province?c`${e.province},`:""}${e.country}</span> <span class="tz">UTC${e.utcOffset>=0?"+":""}${e.utcOffset}</span></button></li>`)}</ul>`:b}</div>${this.error?c`<p class="search-error" role="alert">${this.t(this.error)}</p>`:b}`}};n.styles=[O,$,Q`:host{display:block;position:relative}.field{position:relative}input{inline-size:100%;min-block-size:var(--roxy-touch)}.option .city{font-weight:var(--roxy-weight-bold)}.option .where{color:var(--roxy-muted);flex-grow:1}.option .tz{color:var(--roxy-muted);font-size:var(--roxy-text-xs);font-variant-numeric:tabular-nums}.search-error{margin:var(--roxy-space-xs) 0 0;color:var(--roxy-danger-fg);font-size:var(--roxy-text-sm)}`],i([d({type:String,attribute:"api-key"})],n.prototype,"apiKey",2),i([d({type:String,attribute:"publishable-key"})],n.prototype,"publishableKey",2),i([d({type:String})],n.prototype,"endpoint",2),i([d({type:String,attribute:"submit-url"})],n.prototype,"submitUrl",2),i([d({attribute:"submit-context",converter:I})],n.prototype,"submitContext",2),i([d({type:String})],n.prototype,"placeholder",2),i([d({type:String,attribute:"default-value"})],n.prototype,"defaultValue",2),i([u()],n.prototype,"query",2),i([u()],n.prototype,"results",2),i([u()],n.prototype,"isOpen",2),i([u()],n.prototype,"isLoading",2),i([u()],n.prototype,"highlight",2),i([u()],n.prototype,"refusal",2),i([u()],n.prototype,"error",2),n=i([U("roxy-location-search")],n);export{n as RoxyLocationSearch};
|
|
1
|
+
var j=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var i=(t,e,r,o)=>{for(var n=o>1?void 0:o?H(e,r):e,a=t.length-1,l;a>=0;a--)(l=t[a])&&(n=(o?l(e,r,n):l(n))||n);return o&&n&&j(e,r,n),n};import{css as Z,html as c,nothing as b}from"lit";import{property as d,state as u}from"lit/decorators.js";import{LitElement as D}from"lit";var v='@layer roxy.tokens,roxy.theme;@layer roxy.tokens{:where(:root,:host){color-scheme:light;--roxy-bg: #ffffff;--roxy-fg: #0a0a0a;--roxy-accent: #4a6297;--roxy-success: #16a34a;--roxy-warning: #ea580c;--roxy-danger: #dc2626;--roxy-info: #0284c7;--roxy-accent-ink: color-mix(in oklab, var(--roxy-accent) 70%, black);--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, black);--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, black);--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, black);--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, black);--roxy-font-sans: initial;--roxy-font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;--roxy-text-base: 1rem;--roxy-text-scale: 1.15;--roxy-weight-normal: 400;--roxy-weight-bold: 600;--roxy-leading-tight: 1.25;--roxy-leading-normal: 1.5;--roxy-tracking-tight: -0.01em;--roxy-tracking-normal: 0em;--roxy-space-unit: 0.25rem;--roxy-radius: 6px;--roxy-motion-duration: 200ms;--roxy-motion-easing: cubic-bezier(0.4, 0, 0.2, 1)}:where(:root,:host,[data-theme],.light,.dark){--roxy-surface: var(--roxy-bg);--roxy-primary: var(--roxy-fg);--roxy-secondary: color-mix(in oklab, var(--roxy-fg) 78%, var(--roxy-bg));--roxy-muted: color-mix(in oklab, var(--roxy-fg) 60%, var(--roxy-bg));--roxy-border: color-mix(in oklab, var(--roxy-fg) 14%, var(--roxy-bg));--roxy-ring: color-mix(in srgb, var(--roxy-accent) 40%, transparent);--roxy-heat: var(--roxy-danger);--roxy-font-display: var(--roxy-font-sans);--roxy-text-sm: calc(var(--roxy-text-base) / var(--roxy-text-scale));--roxy-text-xs: calc(var(--roxy-text-sm) / var(--roxy-text-scale));--roxy-text-lg: calc(var(--roxy-text-base) * var(--roxy-text-scale));--roxy-text-xl: calc( var(--roxy-text-lg) * var(--roxy-text-scale) * var(--roxy-text-scale) );--roxy-space-xs: var(--roxy-space-unit);--roxy-space-sm: calc(var(--roxy-space-unit) * 2);--roxy-space-md: calc(var(--roxy-space-unit) * 4);--roxy-space-lg: calc(var(--roxy-space-unit) * 6);--roxy-space-xl: calc(var(--roxy-space-unit) * 10);--roxy-line-thick: calc(var(--roxy-space-unit) / 2);--roxy-touch: calc(var(--roxy-space-unit) * 11);--roxy-radius-sm: calc(var(--roxy-radius) / 2);--roxy-radius-md: var(--roxy-radius);--roxy-radius-lg: calc(var(--roxy-radius) * 5 / 3);--roxy-radius-full: 9999px;--roxy-shadow-sm: none;--roxy-shadow-md: 0 4px 12px color-mix(in srgb, black 10%, transparent);--roxy-shadow-lg: 0 12px 32px color-mix(in srgb, black 18%, transparent)}@media(prefers-color-scheme:dark){:where(:root,:host){color-scheme:dark;--roxy-bg: #0a0a0a;--roxy-fg: #fafafa;--roxy-accent: #92aade;--roxy-success: #22c55e;--roxy-warning: #fb923c;--roxy-danger: #ef4444;--roxy-info: #38bdf8;--roxy-accent-ink: var(--roxy-accent);--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, white);--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, white);--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, white);--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, white)}}:where(:root[data-theme=light],[data-theme=light],:root.light,.light,:host([data-theme="light"])){color-scheme:light;--roxy-bg: #ffffff;--roxy-fg: #0a0a0a;--roxy-accent: #4a6297;--roxy-success: #16a34a;--roxy-warning: #ea580c;--roxy-danger: #dc2626;--roxy-info: #0284c7;--roxy-accent-ink: color-mix(in oklab, var(--roxy-accent) 70%, black);--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, black);--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, black);--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, black);--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, black)}:where(:root[data-theme=dark],[data-theme=dark],:root.dark,.dark,:host([data-theme="dark"])){color-scheme:dark;--roxy-bg: #0a0a0a;--roxy-fg: #fafafa;--roxy-accent: #92aade;--roxy-success: #22c55e;--roxy-warning: #fb923c;--roxy-danger: #ef4444;--roxy-info: #38bdf8;--roxy-accent-ink: var(--roxy-accent);--roxy-success-fg: color-mix(in oklab, var(--roxy-success) 70%, white);--roxy-warning-fg: color-mix(in oklab, var(--roxy-warning) 70%, white);--roxy-danger-fg: color-mix(in oklab, var(--roxy-danger) 70%, white);--roxy-info-fg: color-mix(in oklab, var(--roxy-info) 70%, white)}@media(prefers-reduced-motion:reduce){:where(:root,:host){--roxy-motion-duration: 0ms}}}';var w="roxy-ui-tokens";function k(){if(typeof document>"u")return null;let t=document.getElementById(w);if(t)return t;let e=document.createElement("style");return e.id=w,e.textContent=v,document.head.prepend(e),e}function R(t){if(t.lang)return t.lang;if(typeof document>"u")return;let e=t.closest?.("[lang]")?.getAttribute("lang");return e||document.documentElement.lang||void 0}function C(t){return t.toLowerCase().replace(/[\s_-]+/g," ").trim()}var E="__ROXY_UI_I18N__";function A(){let t=globalThis,e=t[E];if(e)return e;let r={catalogs:{},fieldLabels:{},requested:new Set,listeners:new Set};return t[E]=r,r}function Y(t,e){return e?t.replace(/\{\{(\w+)\}\}/g,(r,o)=>o in e?String(e[o]??""):r):t}function L(t,e,r){return Y(q(t,e)??e,r)}function q(t,e){if(!t)return;let{catalogs:r}=A(),o=t.toLowerCase();return(r[o]??r[o.split("-")[0]])?.[C(e)]}function S(t){let{listeners:e}=A();return e.add(t),()=>{e.delete(t)}}var y=class{constructor(e){this.host=e,e.addController(this)}hostConnected(){this.unsubscribe=S(()=>this.host.requestUpdate())}hostDisconnected(){this.unsubscribe?.(),this.unsubscribe=void 0}};var x=class extends D{constructor(){super();this.translator=(r,o)=>this.t(r,o);new y(this)}connectedCallback(){super.connectedCallback(),k()}t(r,o){return L(this.effectiveLang(),r,o)}effectiveLang(){return R(this)}};import{css as N}from"lit";import{css as M}from"lit";var T=M`:where([part~=card]){background:var(--roxy-surface);color:var(--roxy-fg);border:1px solid var(--roxy-border);border-radius:var(--roxy-radius-lg);box-shadow:var(--roxy-shadow-sm)}:where([part~=card] [part~=card],[part~=card] [part~=reading],[part~=card] .roxy-card){border:0;border-block-start:1px solid var(--roxy-border);box-shadow:none;background:0 0;border-radius:0;padding-inline:0}:host([bare]) [part~=card]{box-shadow:none;background:0 0;border:0;border-radius:0;padding:0}:where(h1,h2){color:var(--roxy-fg);font-size:var(--roxy-text-lg);font-weight:var(--roxy-weight-bold);line-height:var(--roxy-leading-tight);letter-spacing:var(--roxy-tracking-tight);text-wrap:balance}:where(h3,h4,h5,h6){color:var(--roxy-fg);font-size:var(--roxy-text-base);font-weight:var(--roxy-weight-bold);line-height:var(--roxy-leading-tight);letter-spacing:var(--roxy-tracking-normal);text-transform:none}:where(.roxy-label,th,dt){color:var(--roxy-muted);font-size:var(--roxy-text-sm);font-weight:var(--roxy-weight-normal);letter-spacing:var(--roxy-tracking-normal);text-transform:none}:where(.roxy-chips){gap:var(--roxy-space-xs);flex-wrap:wrap;margin:0;padding:0;list-style:none;display:flex}:where(.roxy-chip,.roxy-chips>li){align-items:center;gap:var(--roxy-space-xs);padding:calc(var(--roxy-space-unit) / 2) var(--roxy-space-sm);border:1px solid var(--roxy-border);border-radius:var(--roxy-radius-sm);color:var(--roxy-secondary);font-size:var(--roxy-text-xs);line-height:var(--roxy-leading-tight);overflow-wrap:anywhere;background:0 0;max-inline-size:100%;display:inline-flex}:where(.roxy-chip[data-tone=success],.roxy-chips>li[data-tone=success]){color:var(--roxy-success-fg)}:where(.roxy-chip[data-tone=warning],.roxy-chips>li[data-tone=warning]){color:var(--roxy-warning-fg)}:where(.roxy-chip[data-tone=danger],.roxy-chips>li[data-tone=danger]){color:var(--roxy-danger-fg)}:where(.roxy-chip[data-tone=info],.roxy-chips>li[data-tone=info]){color:var(--roxy-info-fg)}:where(table){border-collapse:collapse;font-size:var(--roxy-text-sm);font-variant-numeric:tabular-nums}:where(th,td){padding:var(--roxy-space-xs) var(--roxy-space-sm);border-block-end:1px solid var(--roxy-border);text-align:start;vertical-align:top}:where(summary){cursor:pointer}:where(a,button,summary,input,select,textarea,[tabindex]):focus-visible{outline:var(--roxy-line-thick) solid var(--roxy-ring);outline-offset:var(--roxy-line-thick)}:where(summary:focus-visible){border-radius:var(--roxy-radius-sm)}:where(input,select,textarea,button){font:inherit}:where(input:not([type=checkbox],[type=radio],[type=range]),select,textarea){padding:var(--roxy-space-xs) var(--roxy-space-sm);background:var(--roxy-bg);color:var(--roxy-fg);border:1px solid var(--roxy-border);border-radius:var(--roxy-radius-md)}`;var G=N`:host{--roxy-label-col:minmax(0, 25%);--_mask:var(--roxy-surface);font-family:var(--roxy-font-sans);color:var(--roxy-fg);font-size:var(--roxy-text-base);line-height:var(--roxy-leading-normal);animation:roxy-fade-in var(--roxy-motion-duration) var(--roxy-motion-easing) both;background:0 0;display:block;container-type:inline-size}:host([bare]){--_mask:var(--roxy-bg)}:host([hidden]){display:none}:host([bare]){--roxy-surface:transparent;--roxy-shadow-sm:none;--roxy-shadow-md:none}*,:before,:after{box-sizing:border-box}h1,h2,h3,h4{font-family:var(--roxy-font-display)}@keyframes roxy-fade-in{0%{transform:translateY(calc(var(--roxy-space-unit) / 2))}to{transform:translateY(0)}}@media (prefers-reduced-motion:reduce){:host{animation:none}}.roxy-skeleton{background:linear-gradient(90deg, var(--roxy-border) 0%, color-mix(in srgb, var(--roxy-border) 60%, transparent) 50%, var(--roxy-border) 100%);border-radius:var(--roxy-radius-md);background-size:200% 100%;animation:1.4s ease-in-out infinite roxy-shimmer}@keyframes roxy-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}@media (prefers-reduced-motion:reduce){.roxy-skeleton{animation:none}}.roxy-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;width:1px;height:1px;margin:0;padding:0;position:absolute;overflow:hidden}.roxy-empty{padding:var(--roxy-space-lg);color:var(--roxy-muted);text-align:center;font-size:var(--roxy-text-sm)}.roxy-error{gap:var(--roxy-space-sm);padding:var(--roxy-space-lg);background:var(--roxy-surface);border:1px solid var(--roxy-danger);border-radius:var(--roxy-radius-md);color:var(--roxy-danger-fg);font-size:var(--roxy-text-sm);justify-items:start;display:grid}:host(:focus-within) .roxy-card{outline:var(--roxy-line-thick) solid var(--roxy-ring);outline-offset:var(--roxy-line-thick)}.roxy-attribution{margin-top:var(--roxy-space-sm);font-size:var(--roxy-text-xs);color:var(--roxy-muted);text-align:right}.roxy-attribution a{color:inherit;text-decoration:none}.roxy-attribution a:hover{color:var(--roxy-accent-ink);text-decoration:underline}.roxy-edit-bar{margin-bottom:var(--roxy-space-sm);justify-content:flex-end;display:flex}.roxy-edit{padding:var(--roxy-space-xs) var(--roxy-space-md);border:1px solid var(--roxy-border);border-radius:var(--roxy-radius-md);color:var(--roxy-fg);font-family:inherit;font-size:var(--roxy-text-sm);cursor:pointer;background:0 0}.roxy-edit:hover{border-color:var(--roxy-accent);color:var(--roxy-accent-ink)}.roxy-edit:disabled{cursor:progress;color:var(--roxy-muted)}roxy-endpoint-form+*{margin-top:var(--roxy-space-md)}.roxy-more{justify-items:center;gap:var(--roxy-space-sm);margin-top:var(--roxy-space-md);display:grid}.roxy-more .roxy-edit{min-height:var(--roxy-touch)}:host{font-variant-emoji:text}`,$=[G,T];import{css as B}from"lit";var K=B`.spinner{inset-inline-end:calc(var(--roxy-space-unit) * 3);border:var(--roxy-line-thick) solid var(--roxy-muted);border-radius:var(--roxy-radius-full);border-top-color:#0000;block-size:.6lh;inline-size:.6lh;animation:.7s linear infinite roxy-spin;position:absolute;top:50%;transform:translateY(-50%)}@keyframes roxy-spin{to{transform:translateY(-50%)rotate(360deg)}}@media (prefers-reduced-motion:reduce){.spinner{animation:none}}.results{z-index:50;top:calc(100% + var(--roxy-space-xs));padding:var(--roxy-space-xs);background:var(--roxy-bg);border:1px solid var(--roxy-border);border-radius:var(--roxy-radius-md);box-shadow:var(--roxy-shadow-md);max-block-size:15lh;animation:roxy-fade-in var(--roxy-motion-duration) var(--roxy-motion-easing);margin:0;list-style:none;position:absolute;left:0;right:0;overflow-y:auto}.option{align-items:center;gap:var(--roxy-space-sm);inline-size:100%;min-block-size:var(--roxy-touch);padding:var(--roxy-space-sm) var(--roxy-space-md);border-radius:var(--roxy-radius-sm);text-align:start;font-size:var(--roxy-text-sm);color:var(--roxy-fg);cursor:pointer;transition:background-color var(--roxy-motion-duration);background:0 0;border:0;display:flex}.option:hover,.option[aria-selected=true]{background:color-mix(in srgb, var(--roxy-accent) 10%, transparent)}.empty{padding:var(--roxy-space-md);color:var(--roxy-muted);font-size:var(--roxy-text-sm)}`;function _(t,e){let r,o=((...n)=>{r&&clearTimeout(r),r=setTimeout(()=>{r=void 0,t(...n)},e)});return o.cancel=()=>{r&&(clearTimeout(r),r=void 0)},o}var O=t=>e=>{customElements.get(t)||customElements.define(t,e)};var X="pk_live_YOUR_KEY",U={secret:{reason:"possible-secret-key",message:"Client-side components accept a pk_ publishable key only. Use a publishable key with an origin allowlist, or render server-side."},sample:{reason:"sample-key",message:"Replace the sample key with your own publishable key from your RoxyAPI account."}};function p(t){if(t)return t===X?U.sample:t.startsWith("pk_")?void 0:U.secret}function f(t,e,r={}){r.warn&&console.warn(e.message),t.dispatchEvent(new CustomEvent("roxy-validation-error",{detail:{reason:e.reason,message:e.message},bubbles:!0,composed:!0}))}var m="https://roxyapi.com/api/v2";async function z(t){return(await F(t)).message}async function F(t){try{let e=await t.json();if(e?.error){let r=e.code==="validation_error"&&Array.isArray(e.issues)?e.issues.filter(o=>typeof o.path=="string"&&typeof o.message=="string").map(o=>({path:o.path,message:o.message})):null;return{message:e.error,issues:r?.length?r:null,worded:!0}}}catch{}return{message:`Request failed (${t.status})`,issues:null,worded:!1}}var P={fromAttribute:t=>{if(t!=null){try{let e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}console.warn("[roxy-ui] submit-context must be a JSON object; sending the request without it.")}}},g=class extends Error{constructor(r,o=null,n=!0){super(r);this.issues=o;this.worded=n}};function J(t){return t.submitUrl?void 0:p(t.publishableKey)}async function I(t,e,r){let o=J(t);if(o)throw new g(o.message);let n=t.submitUrl?await fetch(t.submitUrl,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:V(e,t.submitContext),signal:r}):await W(t,e,r);if(!n.ok){let a=await F(n);throw new g(a.message,a.issues,a.worded)}return await n.json()}function V(t,e){return JSON.stringify(e?{...t,context:e}:t)}function W(t,e,r){let o=new URL(`${t.baseUrl??m}${e.path}`,document.baseURI);for(let[a,l]of Object.entries(e.query??{}))l!=null&&o.searchParams.set(a,String(l));let n={Accept:"application/json"};return t.publishableKey&&(n["X-API-Key"]=t.publishableKey),e.body!=null&&(n["Content-Type"]="application/json"),fetch(o,{method:e.method??"GET",headers:n,body:e.body!=null?JSON.stringify(e.body):void 0,signal:r})}var s=class extends x{constructor(){super(...arguments);this.placeholder="Search city";this.defaultValue="";this.query="";this.results=[];this.isOpen=!1;this.isLoading=!1;this.highlight=-1;this.error=null;this.debouncedFetch=_(r=>{this.fetchResults(r)},300);this.onInput=r=>{let o=r.target.value;if(this.query=o,o.length<2){this.results=[],this.isOpen=!1,this.highlight=-1,this.error=null;return}this.debouncedFetch(o)};this.onKeyDown=r=>{if(!this.isOpen||this.results.length===0){r.key==="ArrowDown"&&this.query.length>=2&&(this.fetchResults(this.query),r.preventDefault());return}if(r.key==="ArrowDown")r.preventDefault(),this.highlight=(this.highlight+1)%this.results.length;else if(r.key==="ArrowUp")r.preventDefault(),this.highlight=(this.highlight-1+this.results.length)%this.results.length;else if(r.key==="Enter"){r.preventDefault();let o=this.results[this.highlight]??this.results[0];o&&this.select(o)}else r.key==="Escape"&&(this.isOpen=!1)}}connectedCallback(){super.connectedCallback(),this.query=this.defaultValue,this.clickOutsideHandler=r=>{r.composedPath().includes(this)||(this.isOpen=!1)},document.addEventListener("mousedown",this.clickOutsideHandler)}willUpdate(r){if(r.has("publishableKey")||r.has("apiKey")){let o=p(this.publishableKey??this.apiKey);o&&!this.refusal&&f(this,o,{warn:!0}),this.refusal=o}}disconnectedCallback(){super.disconnectedCallback(),this.clickOutsideHandler&&document.removeEventListener("mousedown",this.clickOutsideHandler),this.debouncedFetch.cancel(),this.abortController&&(this.abortController.abort(),this.abortController=void 0)}async fetchResults(r){if(this.refusal)return;this.abortController&&this.abortController.abort();let o=new AbortController;this.abortController=o,this.isLoading=!0;try{let n=await this.search(r,o.signal);if(o.signal.aborted)return;this.error=null,this.results=n.cities??[],this.isOpen=!0,this.highlight=this.results.length>0?0:-1}catch(n){if(n?.name==="AbortError")return;this.results=[],this.isOpen=!1,this.highlight=-1,this.error=n instanceof Error?n.message:String(n)}finally{this.abortController===o&&(this.abortController=void 0),o.signal.aborted||(this.isLoading=!1)}}async search(r,o){if(!this.endpoint&&this.submitUrl)return I({submitUrl:this.submitUrl,submitContext:this.submitContext},{path:"/location/search",method:"GET",query:{q:r,limit:8}},o);let n=new URL(this.endpoint||`${m}/location/search`,document.baseURI);n.searchParams.set("q",r),n.searchParams.set("limit","8");let a={Accept:"application/json"};this.apiKey&&this.publishableKey&&console.warn("[roxy-location-search] both api-key and publishable-key set; using publishable-key. Remove api-key from your widget markup.");let l=this.publishableKey??this.apiKey;l&&(a["X-API-Key"]=l);let h=await fetch(n,{headers:a,signal:o});if(!h.ok)throw new Error(await z(h));return await h.json()}select(r){this.query=`${r.city}${r.province?`, ${r.province}`:""}, ${r.country}`,this.isOpen=!1,this.results=[],this.dispatchEvent(new CustomEvent("roxy-location-select",{detail:r,bubbles:!0,composed:!0}))}render(){return this.refusal?c`<div class="roxy-error" role="alert">${this.t(this.refusal.message)}</div>`:c`<div class="field"><input part="input" type="text" role="combobox" aria-expanded="${this.isOpen?"true":"false"}" aria-controls="roxy-location-listbox" aria-activedescendant="${this.isOpen&&this.highlight>=0?`roxy-location-option-${this.highlight}`:""}" aria-autocomplete="list" autocomplete="off" placeholder="${this.t(this.placeholder)}" .value="${this.query}" @input="${this.onInput}" @keydown="${this.onKeyDown}" @focus="${()=>{this.results.length>0&&(this.isOpen=!0)}}"> ${this.isLoading?c`<span class="spinner" role="status" aria-label="${this.t("Loading")}"></span>`:b} ${this.isOpen?c`<ul id="roxy-location-listbox" part="results" class="results" role="listbox">${this.results.length===0?c`<li class="empty" role="status">${this.t("No cities found")}</li>`:this.results.map((r,o)=>c`<li role="presentation"><button type="button" part="option" class="option" role="option" id="${`roxy-location-option-${o}`}" aria-selected="${this.highlight===o?"true":"false"}" @click="${()=>this.select(r)}" @mouseenter="${()=>{this.highlight=o}}"><span class="city">${r.city}</span> <span class="where">${r.province?c`${r.province},`:""}${r.country}</span> <span class="tz">UTC${r.utcOffset>=0?"+":""}${r.utcOffset}</span></button></li>`)}</ul>`:b}</div>${this.error?c`<p class="search-error" role="alert">${this.t(this.error)}</p>`:b}`}};s.styles=[$,K,Z`:host{display:block;position:relative}.field{position:relative}input{inline-size:100%;min-block-size:var(--roxy-touch)}.option .city{font-weight:var(--roxy-weight-bold)}.option .where{color:var(--roxy-muted);flex-grow:1}.option .tz{color:var(--roxy-muted);font-size:var(--roxy-text-xs);font-variant-numeric:tabular-nums}.search-error{margin:var(--roxy-space-xs) 0 0;color:var(--roxy-danger-fg);font-size:var(--roxy-text-sm)}`],i([d({type:String,attribute:"api-key"})],s.prototype,"apiKey",2),i([d({type:String,attribute:"publishable-key"})],s.prototype,"publishableKey",2),i([d({type:String})],s.prototype,"endpoint",2),i([d({type:String,attribute:"submit-url"})],s.prototype,"submitUrl",2),i([d({attribute:"submit-context",converter:P})],s.prototype,"submitContext",2),i([d({type:String})],s.prototype,"placeholder",2),i([d({type:String,attribute:"default-value"})],s.prototype,"defaultValue",2),i([u()],s.prototype,"query",2),i([u()],s.prototype,"results",2),i([u()],s.prototype,"isOpen",2),i([u()],s.prototype,"isLoading",2),i([u()],s.prototype,"highlight",2),i([u()],s.prototype,"refusal",2),i([u()],s.prototype,"error",2),s=i([O("roxy-location-search")],s);export{s as RoxyLocationSearch};
|