@florid-kit/components 2.6.18 → 3.0.0
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/assets/icons/icons-occ.d.ts +315 -0
- package/assets/icons/icons.d.ts +12 -84
- package/assets/icons/svg-utils.d.ts +13 -0
- package/behaviors/performance-mixin.d.ts +0 -23
- package/behaviors/performance-reporter.d.ts +1 -0
- package/components/accordion-group.mjs +61 -0
- package/components/accordion.mjs +185 -0
- package/components/arch-image.mjs +135 -0
- package/components/badge.mjs +75 -0
- package/components/breadcrumb.mjs +83 -0
- package/components/breadcrumbs.mjs +35 -0
- package/components/button.d.ts +3 -0
- package/components/button.mjs +12 -0
- package/components/checkbox.mjs +188 -0
- package/components/chip.mjs +158 -0
- package/components/chipset.mjs +44 -0
- package/components/dots.mjs +60 -0
- package/components/dropdown-variant.d.ts +1 -0
- package/components/dropdown-variant.mjs +446 -0
- package/components/dropdown.d.ts +1 -0
- package/components/dropdown.mjs +303 -0
- package/components/feedback-message.mjs +136 -0
- package/components/filter-chip.mjs +215 -0
- package/components/footer-simplify.mjs +178 -0
- package/components/header-simplify.mjs +234 -0
- package/components/icon-button.d.ts +5 -0
- package/components/icon-button.mjs +340 -0
- package/components/input.mjs +298 -0
- package/components/link.mjs +172 -0
- package/components/mediumtile.mjs +307 -0
- package/components/minitile.mjs +234 -0
- package/components/option-tile-group.mjs +105 -0
- package/components/option-tile.mjs +413 -0
- package/components/popin.mjs +412 -0
- package/components/radio.mjs +165 -0
- package/components/rating.mjs +81 -0
- package/components/reassurance.mjs +163 -0
- package/components/search-input-dropdown.mjs +314 -0
- package/components/search-input.mjs +107 -0
- package/components/side-panel.mjs +1206 -0
- package/components/tab.mjs +140 -0
- package/components/tablist.mjs +44 -0
- package/components/tag.mjs +86 -0
- package/components/textarea.mjs +269 -0
- package/components/thumbnail-navigation.mjs +232 -0
- package/components/toast.mjs +191 -0
- package/components/tooltip.mjs +125 -0
- package/components/wishlist-button.mjs +132 -0
- package/css-C8WrrxT-.mjs +41 -0
- package/directive-helpers-BHuwIghp.mjs +11 -0
- package/directive-oAbCiebi.mjs +27 -0
- package/element-internals-Dw7LndlH.mjs +19 -0
- package/icons-Pdn_6YtT.mjs +104 -0
- package/icons-occ.mjs +834 -0
- package/if-defined-j0wE2gL4.mjs +10 -0
- package/index.mjs +41 -9719
- package/live-C_TUoYRm.mjs +30 -0
- package/loader.d.ts +3 -0
- package/loader.mjs +78 -0
- package/logo-CEgaTL93.mjs +4 -0
- package/package.json +19 -1
- package/performance-mixin-D7YmSeqN.mjs +628 -0
- package/performance-reporter-B7ZOqnDk.mjs +89 -0
- package/property-S_Y9cb04.mjs +36 -0
- package/query-NJDNu0-P.mjs +25 -0
- package/state-DjMxXomO.mjs +12 -0
- package/svg-utils-CRDBD8ES.mjs +47 -0
- package/unsafe-svg-C3uTocNg.mjs +34 -0
- package/index.js +0 -5755
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { i as f, m as g, a as v, x as p, t as m } from "../performance-mixin-D7YmSeqN.mjs";
|
|
2
|
+
import { n as c } from "../property-S_Y9cb04.mjs";
|
|
3
|
+
import { o as h } from "../unsafe-svg-C3uTocNg.mjs";
|
|
4
|
+
import { b as u } from "../icons-Pdn_6YtT.mjs";
|
|
5
|
+
import "./link.mjs";
|
|
6
|
+
var y = Object.defineProperty, d = Object.getOwnPropertyDescriptor, a = (s, t, e, r) => {
|
|
7
|
+
for (var i = r > 1 ? void 0 : r ? d(t, e) : t, o = s.length - 1, l; o >= 0; o--)
|
|
8
|
+
(l = s[o]) && (i = (r ? l(t, e, i) : l(i)) || i);
|
|
9
|
+
return r && i && y(t, e, i), i;
|
|
10
|
+
};
|
|
11
|
+
let n = class extends g(v) {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.rating = 0;
|
|
14
|
+
}
|
|
15
|
+
getStarKeys() {
|
|
16
|
+
const s = [];
|
|
17
|
+
for (let t = 0; t < 5; t++) {
|
|
18
|
+
const e = this.rating - t;
|
|
19
|
+
let r;
|
|
20
|
+
e >= 1 ? r = 100 : e <= 0 ? r = 0 : r = Math.round(e * 100 / 25) * 25, s.push(`occ-star-${r}`);
|
|
21
|
+
}
|
|
22
|
+
return s;
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
const s = this.getStarKeys();
|
|
26
|
+
return p`
|
|
27
|
+
<div class="rating">
|
|
28
|
+
<div class="stars">
|
|
29
|
+
${s.map(
|
|
30
|
+
(t) => {
|
|
31
|
+
const { svg: e } = u(t, { size: "small", bgstyle: "none-contrast" });
|
|
32
|
+
return p`<span class="star">${h(e)}</span>`;
|
|
33
|
+
}
|
|
34
|
+
)}
|
|
35
|
+
</div>
|
|
36
|
+
${this.reviewCount != null && this.href != null ? p`<o-link template="review" href="${this.href}">${this.reviewCount}</o-link>` : null}
|
|
37
|
+
</div>
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
n.styles = f`
|
|
42
|
+
.rating {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.stars {
|
|
48
|
+
display: flex;
|
|
49
|
+
gap: 2px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.star {
|
|
53
|
+
display: block;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
o-link {
|
|
57
|
+
margin-left: 6px;
|
|
58
|
+
font-family: var(--font-family-loccitane-sans);
|
|
59
|
+
font-weight: var(--font-weight-500);
|
|
60
|
+
font-size: var(--font-size-100);
|
|
61
|
+
line-height: var(--line-height-160);
|
|
62
|
+
letter-spacing: var(--letter-spacing-400);
|
|
63
|
+
color: var(--color-content-action-secondary);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
`;
|
|
67
|
+
a([
|
|
68
|
+
c({ type: Number })
|
|
69
|
+
], n.prototype, "rating", 2);
|
|
70
|
+
a([
|
|
71
|
+
c({ type: String })
|
|
72
|
+
], n.prototype, "reviewCount", 2);
|
|
73
|
+
a([
|
|
74
|
+
c({ type: String })
|
|
75
|
+
], n.prototype, "href", 2);
|
|
76
|
+
n = a([
|
|
77
|
+
m("o-rating")
|
|
78
|
+
], n);
|
|
79
|
+
export {
|
|
80
|
+
n as OccitaneRating
|
|
81
|
+
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { T as m, i as f, m as b, a as g, x as l, t as x } from "../performance-mixin-D7YmSeqN.mjs";
|
|
2
|
+
import { n as d } from "../property-S_Y9cb04.mjs";
|
|
3
|
+
import { o as c } from "../if-defined-j0wE2gL4.mjs";
|
|
4
|
+
import { e as v, i as w, t as y } from "../directive-oAbCiebi.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2018 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
+
*/
|
|
10
|
+
const h = "important", $ = " !" + h, k = v(class extends w {
|
|
11
|
+
constructor(s) {
|
|
12
|
+
var t;
|
|
13
|
+
if (super(s), s.type !== y.ATTRIBUTE || s.name !== "style" || ((t = s.strings) == null ? void 0 : t.length) > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
|
|
14
|
+
}
|
|
15
|
+
render(s) {
|
|
16
|
+
return Object.keys(s).reduce((t, i) => {
|
|
17
|
+
const e = s[i];
|
|
18
|
+
return e == null ? t : t + `${i = i.includes("-") ? i : i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${e};`;
|
|
19
|
+
}, "");
|
|
20
|
+
}
|
|
21
|
+
update(s, [t]) {
|
|
22
|
+
const { style: i } = s.element;
|
|
23
|
+
if (this.ft === void 0) return this.ft = new Set(Object.keys(t)), this.render(t);
|
|
24
|
+
for (const e of this.ft) t[e] == null && (this.ft.delete(e), e.includes("-") ? i.removeProperty(e) : i[e] = null);
|
|
25
|
+
for (const e in t) {
|
|
26
|
+
const r = t[e];
|
|
27
|
+
if (r != null) {
|
|
28
|
+
this.ft.add(e);
|
|
29
|
+
const a = typeof r == "string" && r.endsWith($);
|
|
30
|
+
e.includes("-") || a ? i.setProperty(e, a ? r.slice(0, -11) : r, a ? h : "") : i[e] = r;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return m;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var z = Object.defineProperty, O = Object.getOwnPropertyDescriptor, p = (s, t, i, e) => {
|
|
37
|
+
for (var r = e > 1 ? void 0 : e ? O(t, i) : t, a = s.length - 1, o; a >= 0; a--)
|
|
38
|
+
(o = s[a]) && (r = (e ? o(t, i, r) : o(r)) || r);
|
|
39
|
+
return e && r && z(t, i, r), r;
|
|
40
|
+
};
|
|
41
|
+
let n = class extends b(g) {
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments), this.option = {}, this.imageSize = 64, this.fullwidth = !1;
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
const s = (o) => {
|
|
47
|
+
const u = document.createElement("textarea");
|
|
48
|
+
return u.innerHTML = o, u.value;
|
|
49
|
+
}, t = this.option && this.option.clickable, i = {
|
|
50
|
+
width: `${this.imageSize}px`,
|
|
51
|
+
height: `${this.imageSize}px`
|
|
52
|
+
}, e = this.option && this.option.title ? s(this.option.title) : "", r = this.option && this.option.description ? s(this.option.description) : "", a = l`
|
|
53
|
+
${this.option.imgurl ? l`<img src="${this.option.imgurl}" alt="${c(e)}" aria-hidden="true" style=${k(i)} />` : ""}
|
|
54
|
+
<div class="m-reassurance-content">
|
|
55
|
+
<h3 class="a-reassurance-text">${c(e)}</h3>
|
|
56
|
+
<p class="a-reassurance-description">${c(r)}</p>
|
|
57
|
+
</div>
|
|
58
|
+
`;
|
|
59
|
+
return t ? l`<a href="${c(this.option.url)}" class="reassurance-item ${this.fullwidth ? "fullwidth" : ""} clickable">${a}</a>` : l`<div class="reassurance-item ${this.fullwidth ? "fullwidth" : ""}">${a}</div>`;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
n.styles = f`
|
|
63
|
+
:host {
|
|
64
|
+
display: inline-block;
|
|
65
|
+
position: relative;
|
|
66
|
+
width: 100%;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.reassurance-item {
|
|
70
|
+
display: flex;
|
|
71
|
+
column-gap: var(--spacing-xl);
|
|
72
|
+
align-items: center;
|
|
73
|
+
border: var(--border-m) solid var(--color-alpha-dark-lightest);
|
|
74
|
+
background-color: var(--color-container-bg-white);
|
|
75
|
+
border-radius: var(--radius-m);
|
|
76
|
+
padding: var(--spacing-xl);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.reassurance-item.fullwidth {
|
|
80
|
+
width: 100%;
|
|
81
|
+
max-width: 100%;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.reassurance-item:has(img) {
|
|
85
|
+
padding: 3px var(--spacing-s) 3px var(--spacing-2-xs);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.reassurance-item.clickable {
|
|
89
|
+
text-decoration: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.reassurance-item.clickable:disabled {
|
|
93
|
+
box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.06);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.reassurance-item.clickable:hover {
|
|
97
|
+
border: none;
|
|
98
|
+
box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.12);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.reassurance-item.clickable:active {
|
|
102
|
+
border: none;
|
|
103
|
+
box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.32);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.reassurance-item img {
|
|
107
|
+
display: block;
|
|
108
|
+
aspect-ratio: 1 / 1;
|
|
109
|
+
border-radius: var(--radius-s);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.reassurance-item .m-reassurance-content {
|
|
113
|
+
display: flex;
|
|
114
|
+
flex-direction: column;
|
|
115
|
+
justify-content: flex-start;
|
|
116
|
+
row-gap: var(--spacing-3-xs);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.reassurance-item .a-reassurance-text {
|
|
120
|
+
color: var(--color-content-body);
|
|
121
|
+
font-family: var(--font-family-loccitane-sans);
|
|
122
|
+
font-size: var(--font-size-100);
|
|
123
|
+
font-weight: var(--font-weight-500);
|
|
124
|
+
line-height: var(--line-height-160);
|
|
125
|
+
letter-spacing: var(--letter-spacing-400);
|
|
126
|
+
text-transform: uppercase;
|
|
127
|
+
margin: var(--spacing-4-xs);
|
|
128
|
+
display: -webkit-box;
|
|
129
|
+
-webkit-line-clamp: 1;
|
|
130
|
+
line-clamp: 1;
|
|
131
|
+
-webkit-box-orient: vertical;
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.reassurance-item .a-reassurance-description {
|
|
136
|
+
color: var(--color-content-description);
|
|
137
|
+
font-family: var(--font-family-loccitane-sans);
|
|
138
|
+
font-size: var(--font-size-150);
|
|
139
|
+
font-weight: var(--font-weight-400);
|
|
140
|
+
line-height: var(--line-height-200);
|
|
141
|
+
margin: var(--spacing-4-xs);
|
|
142
|
+
display: -webkit-box;
|
|
143
|
+
-webkit-line-clamp: 2;
|
|
144
|
+
line-clamp: 2;
|
|
145
|
+
-webkit-box-orient: vertical;
|
|
146
|
+
overflow: hidden;
|
|
147
|
+
}
|
|
148
|
+
`;
|
|
149
|
+
p([
|
|
150
|
+
d({ type: Object, reflect: !0 })
|
|
151
|
+
], n.prototype, "option", 2);
|
|
152
|
+
p([
|
|
153
|
+
d({ type: Number, reflect: !0 })
|
|
154
|
+
], n.prototype, "imageSize", 2);
|
|
155
|
+
p([
|
|
156
|
+
d({ type: Boolean })
|
|
157
|
+
], n.prototype, "fullwidth", 2);
|
|
158
|
+
n = p([
|
|
159
|
+
x("o-reassurance")
|
|
160
|
+
], n);
|
|
161
|
+
export {
|
|
162
|
+
n as OccitaneReassurance
|
|
163
|
+
};
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { a as d, i as u, m as f, x as h, t as v } from "../performance-mixin-D7YmSeqN.mjs";
|
|
2
|
+
import { n as r } from "../property-S_Y9cb04.mjs";
|
|
3
|
+
import { r as p } from "../state-DjMxXomO.mjs";
|
|
4
|
+
import { e as b } from "../query-NJDNu0-P.mjs";
|
|
5
|
+
import "./search-input.mjs";
|
|
6
|
+
var g = Object.defineProperty, y = Object.getOwnPropertyDescriptor, s = (e, t, i, a) => {
|
|
7
|
+
for (var n = a > 1 ? void 0 : a ? y(t, i) : t, c = e.length - 1, l; c >= 0; c--)
|
|
8
|
+
(l = e[c]) && (n = (a ? l(t, i, n) : l(n)) || n);
|
|
9
|
+
return a && n && g(t, i, n), n;
|
|
10
|
+
};
|
|
11
|
+
let x = 0, o = class extends f(d) {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.label = "", this.value = "", this.placeholder = "Search...", this.helperText = "", this.state = "default", this.disabled = !1, this.theme = "default", this.options = [], this.searchBy = "value", this.noResultsText = "No results found", this.open = !1, this.filteredOptions = [], this.activeIndex = -1, this._listboxId = `o-search-dropdown-listbox-${++x}`, this._handleOutsideClick = (e) => {
|
|
14
|
+
this.contains(e.target) || (this.open = !1, this.activeIndex = -1);
|
|
15
|
+
}, this._handleFocusOut = () => {
|
|
16
|
+
requestAnimationFrame(() => {
|
|
17
|
+
this.renderRoot.activeElement || (this.open = !1, this.activeIndex = -1);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
connectedCallback() {
|
|
22
|
+
super.connectedCallback(), document.addEventListener("click", this._handleOutsideClick), this.addEventListener("focusout", this._handleFocusOut);
|
|
23
|
+
}
|
|
24
|
+
disconnectedCallback() {
|
|
25
|
+
document.removeEventListener("click", this._handleOutsideClick), this.removeEventListener("focusout", this._handleFocusOut), super.disconnectedCallback();
|
|
26
|
+
}
|
|
27
|
+
filterOptions(e) {
|
|
28
|
+
if (!e.trim()) return [];
|
|
29
|
+
const t = e.toLowerCase();
|
|
30
|
+
return this.options.filter((i) => {
|
|
31
|
+
switch (this.searchBy) {
|
|
32
|
+
case "id":
|
|
33
|
+
return i.id.toLowerCase().includes(t);
|
|
34
|
+
case "both":
|
|
35
|
+
return i.id.toLowerCase().includes(t) || i.value.toLowerCase().includes(t);
|
|
36
|
+
default:
|
|
37
|
+
return i.value.toLowerCase().includes(t);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
handleSearch(e) {
|
|
42
|
+
const t = e.detail.value ?? "";
|
|
43
|
+
this.value = t, this.filteredOptions = this.filterOptions(t), this.open = t.trim().length > 0, this.activeIndex = -1;
|
|
44
|
+
}
|
|
45
|
+
selectOption(e) {
|
|
46
|
+
var t;
|
|
47
|
+
this.value = e.value, this.filteredOptions = [], this.open = !1, this.activeIndex = -1, this.dispatchEvent(
|
|
48
|
+
new CustomEvent("select", {
|
|
49
|
+
detail: { id: e.id, value: e.value },
|
|
50
|
+
bubbles: !0,
|
|
51
|
+
composed: !0
|
|
52
|
+
})
|
|
53
|
+
), (t = this.onSelect) == null || t.call(this, e), this.updateComplete.then(() => {
|
|
54
|
+
var i;
|
|
55
|
+
return (i = this.searchInputEl) == null ? void 0 : i.focus();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
scrollActiveIntoView() {
|
|
59
|
+
this.updateComplete.then(() => {
|
|
60
|
+
var t;
|
|
61
|
+
const e = (t = this.renderRoot) == null ? void 0 : t.querySelector(`#suggestion-${this.activeIndex}`);
|
|
62
|
+
e == null || e.scrollIntoView({ block: "nearest" });
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Keyboard handler while focus is in the search input.
|
|
67
|
+
*
|
|
68
|
+
* Arrow ↓/↑ — highlight options (active-descendant, focus stays in input)
|
|
69
|
+
* Enter — select highlighted option
|
|
70
|
+
* Escape — close dropdown
|
|
71
|
+
* Tab — browser handles naturally:
|
|
72
|
+
* input → clear button (×) → li[0] → … → li[n] → li[0] (loop)
|
|
73
|
+
*/
|
|
74
|
+
handleKeyDown(e) {
|
|
75
|
+
switch (e.key) {
|
|
76
|
+
case "ArrowDown":
|
|
77
|
+
e.preventDefault(), !this.open && this.filteredOptions.length > 0 ? (this.open = !0, this.activeIndex = 0) : this.open && this.filteredOptions.length > 0 && (this.activeIndex = (this.activeIndex + 1) % this.filteredOptions.length), this.scrollActiveIntoView();
|
|
78
|
+
break;
|
|
79
|
+
case "ArrowUp":
|
|
80
|
+
e.preventDefault(), this.open && this.filteredOptions.length > 0 && (this.activeIndex = (this.activeIndex - 1 + this.filteredOptions.length) % this.filteredOptions.length, this.scrollActiveIntoView());
|
|
81
|
+
break;
|
|
82
|
+
case "Enter":
|
|
83
|
+
this.open && this.activeIndex >= 0 && this.filteredOptions[this.activeIndex] && (e.preventDefault(), this.selectOption(this.filteredOptions[this.activeIndex]));
|
|
84
|
+
break;
|
|
85
|
+
case "Escape":
|
|
86
|
+
this.open && (e.preventDefault(), this.open = !1, this.activeIndex = -1);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Keyboard handler while focus is on a list item.
|
|
92
|
+
*
|
|
93
|
+
* Arrow ↓ — next item (wraps to first)
|
|
94
|
+
* Arrow ↑ — previous item; ArrowUp on first item returns to input
|
|
95
|
+
* Enter/Space — select the focused item
|
|
96
|
+
* Escape — close dropdown and return focus to input
|
|
97
|
+
* Tab — loop: last item → li[0], otherwise move to next item naturally
|
|
98
|
+
* Shift+Tab — browser handles naturally (previous li, or back to clear button / input)
|
|
99
|
+
*/
|
|
100
|
+
handleListKeyDown(e) {
|
|
101
|
+
var a, n, c;
|
|
102
|
+
const t = Array.from(
|
|
103
|
+
this.renderRoot.querySelectorAll('li[role="option"]:not(.no-results)')
|
|
104
|
+
), i = t.indexOf(this.renderRoot.activeElement);
|
|
105
|
+
switch (e.key) {
|
|
106
|
+
case "ArrowDown": {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
const l = t[i + 1] ?? t[0];
|
|
109
|
+
l == null || l.focus();
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case "ArrowUp":
|
|
113
|
+
e.preventDefault(), i <= 0 ? (this.activeIndex = -1, (a = this.searchInputEl) == null || a.focus()) : t[i - 1].focus();
|
|
114
|
+
break;
|
|
115
|
+
case "Enter":
|
|
116
|
+
case " ":
|
|
117
|
+
i >= 0 && this.filteredOptions[i] && (e.preventDefault(), this.selectOption(this.filteredOptions[i]));
|
|
118
|
+
break;
|
|
119
|
+
case "Escape":
|
|
120
|
+
e.preventDefault(), this.open = !1, this.activeIndex = -1, (n = this.searchInputEl) == null || n.focus();
|
|
121
|
+
break;
|
|
122
|
+
case "Tab":
|
|
123
|
+
!e.shiftKey && i === t.length - 1 && (e.preventDefault(), (c = t[0]) == null || c.focus());
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
render() {
|
|
128
|
+
return h`
|
|
129
|
+
<o-search-input
|
|
130
|
+
role="combobox"
|
|
131
|
+
aria-haspopup="listbox"
|
|
132
|
+
aria-expanded="${this.open}"
|
|
133
|
+
aria-autocomplete="list"
|
|
134
|
+
aria-controls="${this._listboxId}"
|
|
135
|
+
aria-activedescendant="${this.open && this.activeIndex >= 0 ? `suggestion-${this.activeIndex}` : ""}"
|
|
136
|
+
label=${this.label}
|
|
137
|
+
value=${this.value}
|
|
138
|
+
placeholder=${this.placeholder}
|
|
139
|
+
helper-text=${this.helperText}
|
|
140
|
+
state=${this.state}
|
|
141
|
+
?disabled=${this.disabled}
|
|
142
|
+
theme=${this.theme}
|
|
143
|
+
trigger="input"
|
|
144
|
+
@search=${this.handleSearch}
|
|
145
|
+
@keydown=${this.handleKeyDown}
|
|
146
|
+
></o-search-input>
|
|
147
|
+
|
|
148
|
+
${this.open ? h`
|
|
149
|
+
<ul
|
|
150
|
+
id="${this._listboxId}"
|
|
151
|
+
role="listbox"
|
|
152
|
+
aria-label="Search suggestions"
|
|
153
|
+
@keydown=${this.handleListKeyDown}
|
|
154
|
+
>
|
|
155
|
+
${this.filteredOptions.length > 0 ? this.filteredOptions.map(
|
|
156
|
+
(e, t) => h`
|
|
157
|
+
<li
|
|
158
|
+
id="suggestion-${t}"
|
|
159
|
+
role="option"
|
|
160
|
+
tabindex="0"
|
|
161
|
+
aria-selected="${t === this.activeIndex}"
|
|
162
|
+
class="${t === this.activeIndex ? "active" : ""}"
|
|
163
|
+
@focus=${() => {
|
|
164
|
+
this.activeIndex = t;
|
|
165
|
+
}}
|
|
166
|
+
@mousedown=${(i) => i.preventDefault()}
|
|
167
|
+
@click=${() => this.selectOption(e)}
|
|
168
|
+
>
|
|
169
|
+
<span>${e.value}</span>
|
|
170
|
+
</li>
|
|
171
|
+
`
|
|
172
|
+
) : h`
|
|
173
|
+
<li class="no-results" role="option" aria-disabled="true">
|
|
174
|
+
<span>${this.noResultsText}</span>
|
|
175
|
+
</li>
|
|
176
|
+
`}
|
|
177
|
+
</ul>
|
|
178
|
+
` : null}
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
o.shadowRootOptions = {
|
|
183
|
+
...d.shadowRootOptions,
|
|
184
|
+
delegatesFocus: !0
|
|
185
|
+
};
|
|
186
|
+
o.styles = u`
|
|
187
|
+
:host {
|
|
188
|
+
display: flex;
|
|
189
|
+
position: relative;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
o-search-input {
|
|
193
|
+
flex: 1;
|
|
194
|
+
/* Remove the 1px focus ring that makes the border appear thicker on focus */
|
|
195
|
+
--o-input-focus-ring: none;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
:host([theme="light"]) o-search-input {
|
|
199
|
+
--o-input-icon-color: var(--color-content-body-inverse, #fffefe);
|
|
200
|
+
--color-border-secondary: var(--color-alpha-light-stronger, rgba(255, 255, 255, 0.68));
|
|
201
|
+
--color-border-primary: var(--color-alpha-light-stronger, rgba(255, 255, 255, 0.68));
|
|
202
|
+
--color-content-body: var(--color-content-body-inverse, #fffefe);
|
|
203
|
+
--color-content-disabled: var(--color-alpha-light-strong, rgba(255, 255, 255, 0.56));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
ul {
|
|
207
|
+
list-style: none;
|
|
208
|
+
margin: 4px 0 0 0;
|
|
209
|
+
padding: 0;
|
|
210
|
+
border: var(--border-m) solid var(--color-border-secondary);
|
|
211
|
+
position: absolute;
|
|
212
|
+
top: 100%;
|
|
213
|
+
left: 0;
|
|
214
|
+
right: 0;
|
|
215
|
+
background-color: var(--color-container-action-secondary-default, #FBF9F6);
|
|
216
|
+
overflow-y: auto;
|
|
217
|
+
z-index: 1000;
|
|
218
|
+
border-radius: var(--radius-200);
|
|
219
|
+
max-height: calc(5 * 40px);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
li {
|
|
223
|
+
display: flex;
|
|
224
|
+
align-items: center;
|
|
225
|
+
padding: var(--spacing-s) var(--spacing-l) var(--spacing-s) var(--spacing-s);
|
|
226
|
+
cursor: pointer;
|
|
227
|
+
border-bottom: var(--border-s) solid var(--color-border-secondary);
|
|
228
|
+
outline: none;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
li:last-child {
|
|
232
|
+
border-bottom: none;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
li span {
|
|
236
|
+
font-family: var(--font-family-loccitane-sans);
|
|
237
|
+
font-weight: var(--font-weight-400);
|
|
238
|
+
font-size: var(--font-size-150);
|
|
239
|
+
line-height: var(--line-height-200);
|
|
240
|
+
letter-spacing: var(--letter-spacing-000);
|
|
241
|
+
color: var(--color-content-body);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/* Unified highlight: hover, arrow-key navigation (.active), and real keyboard focus */
|
|
245
|
+
li:hover:not(.no-results),
|
|
246
|
+
li.active:not(.no-results),
|
|
247
|
+
li:focus:not(.no-results) {
|
|
248
|
+
background-color: var(--color-container-action-secondary-hover);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
li:active:not(.no-results) {
|
|
252
|
+
background-color: var(--color-container-action-secondary-pressed);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
li.no-results {
|
|
256
|
+
cursor: default;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
li.no-results span {
|
|
260
|
+
color: var(--color-content-disabled);
|
|
261
|
+
font-style: italic;
|
|
262
|
+
}
|
|
263
|
+
`;
|
|
264
|
+
s([
|
|
265
|
+
r({ type: String })
|
|
266
|
+
], o.prototype, "label", 2);
|
|
267
|
+
s([
|
|
268
|
+
r({ type: String })
|
|
269
|
+
], o.prototype, "value", 2);
|
|
270
|
+
s([
|
|
271
|
+
r({ type: String })
|
|
272
|
+
], o.prototype, "placeholder", 2);
|
|
273
|
+
s([
|
|
274
|
+
r({ type: String, attribute: "helper-text" })
|
|
275
|
+
], o.prototype, "helperText", 2);
|
|
276
|
+
s([
|
|
277
|
+
r({ type: String, reflect: !0 })
|
|
278
|
+
], o.prototype, "state", 2);
|
|
279
|
+
s([
|
|
280
|
+
r({ type: Boolean, reflect: !0 })
|
|
281
|
+
], o.prototype, "disabled", 2);
|
|
282
|
+
s([
|
|
283
|
+
r({ type: String, reflect: !0 })
|
|
284
|
+
], o.prototype, "theme", 2);
|
|
285
|
+
s([
|
|
286
|
+
r({ type: Array })
|
|
287
|
+
], o.prototype, "options", 2);
|
|
288
|
+
s([
|
|
289
|
+
r({ type: String, attribute: "search-by" })
|
|
290
|
+
], o.prototype, "searchBy", 2);
|
|
291
|
+
s([
|
|
292
|
+
r({ type: String, attribute: "no-results-text" })
|
|
293
|
+
], o.prototype, "noResultsText", 2);
|
|
294
|
+
s([
|
|
295
|
+
r({ attribute: !1 })
|
|
296
|
+
], o.prototype, "onSelect", 2);
|
|
297
|
+
s([
|
|
298
|
+
p()
|
|
299
|
+
], o.prototype, "open", 2);
|
|
300
|
+
s([
|
|
301
|
+
p()
|
|
302
|
+
], o.prototype, "filteredOptions", 2);
|
|
303
|
+
s([
|
|
304
|
+
p()
|
|
305
|
+
], o.prototype, "activeIndex", 2);
|
|
306
|
+
s([
|
|
307
|
+
b("o-search-input")
|
|
308
|
+
], o.prototype, "searchInputEl", 2);
|
|
309
|
+
o = s([
|
|
310
|
+
v("o-search-input-dropdown")
|
|
311
|
+
], o);
|
|
312
|
+
export {
|
|
313
|
+
o as OccitaneSearchInputDropdown
|
|
314
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { a as p, i as c, m as d, x as u, t as g } from "../performance-mixin-D7YmSeqN.mjs";
|
|
2
|
+
import { n as o } from "../property-S_Y9cb04.mjs";
|
|
3
|
+
import "./input.mjs";
|
|
4
|
+
var f = Object.defineProperty, y = Object.getOwnPropertyDescriptor, t = (r, i, s, l) => {
|
|
5
|
+
for (var a = l > 1 ? void 0 : l ? y(i, s) : i, h = r.length - 1, n; h >= 0; h--)
|
|
6
|
+
(n = r[h]) && (a = (l ? n(i, s, a) : n(a)) || a);
|
|
7
|
+
return l && a && f(i, s, a), a;
|
|
8
|
+
};
|
|
9
|
+
let e = class extends d(p) {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments), this.label = "", this.value = "", this.placeholder = "Search...", this.helperText = "", this.state = "default", this.disabled = !1, this.theme = "default", this.trigger = "input";
|
|
12
|
+
}
|
|
13
|
+
dispatchSearch() {
|
|
14
|
+
var r;
|
|
15
|
+
this.dispatchEvent(
|
|
16
|
+
new CustomEvent("search", {
|
|
17
|
+
detail: { value: this.value },
|
|
18
|
+
bubbles: !0,
|
|
19
|
+
composed: !0
|
|
20
|
+
})
|
|
21
|
+
), (r = this.onSearch) == null || r.call(this, this.value);
|
|
22
|
+
}
|
|
23
|
+
handleInput(r) {
|
|
24
|
+
const i = r.target;
|
|
25
|
+
this.value = i.value, this.trigger === "input" && this.dispatchSearch();
|
|
26
|
+
}
|
|
27
|
+
handleKeyDown(r) {
|
|
28
|
+
r.key === "Enter" && this.trigger === "enter" && this.dispatchSearch();
|
|
29
|
+
}
|
|
30
|
+
handleChange() {
|
|
31
|
+
this.trigger === "change" && this.dispatchSearch();
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
return u`
|
|
35
|
+
<o-input
|
|
36
|
+
label=${this.label}
|
|
37
|
+
value=${this.value}
|
|
38
|
+
placeholder=${this.placeholder}
|
|
39
|
+
helper-text=${this.helperText}
|
|
40
|
+
state=${this.state}
|
|
41
|
+
?disabled=${this.disabled}
|
|
42
|
+
leading-icon="occ-search"
|
|
43
|
+
trailing-icon=${this.value ? "occ-close-outlined" : ""}
|
|
44
|
+
@input=${this.handleInput}
|
|
45
|
+
@change=${this.handleChange}
|
|
46
|
+
@keydown=${this.handleKeyDown}
|
|
47
|
+
></o-input>
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
e.shadowRootOptions = {
|
|
52
|
+
...p.shadowRootOptions,
|
|
53
|
+
delegatesFocus: !0
|
|
54
|
+
};
|
|
55
|
+
e.styles = c`
|
|
56
|
+
:host {
|
|
57
|
+
display: flex;
|
|
58
|
+
/* Transparent background for all themes */
|
|
59
|
+
--color-container-bg-default: transparent;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
o-input {
|
|
63
|
+
flex: 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Light theme: white/alpha colors for use on dark backgrounds */
|
|
67
|
+
:host([theme="light"]) o-input {
|
|
68
|
+
--o-input-icon-color: var(--color-content-body-inverse, #fffefe);
|
|
69
|
+
--color-border-secondary: var(--color-alpha-light-stronger, rgba(255, 255, 255, 0.68));
|
|
70
|
+
--color-border-primary: var(--color-alpha-light-stronger, rgba(255, 255, 255, 0.68));
|
|
71
|
+
--color-content-body: var(--color-content-body-inverse, #fffefe);
|
|
72
|
+
--color-content-disabled: var(--color-alpha-light-strong, rgba(255, 255, 255, 0.56));
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
t([
|
|
76
|
+
o({ type: String })
|
|
77
|
+
], e.prototype, "label", 2);
|
|
78
|
+
t([
|
|
79
|
+
o({ type: String })
|
|
80
|
+
], e.prototype, "value", 2);
|
|
81
|
+
t([
|
|
82
|
+
o({ type: String })
|
|
83
|
+
], e.prototype, "placeholder", 2);
|
|
84
|
+
t([
|
|
85
|
+
o({ type: String, attribute: "helper-text" })
|
|
86
|
+
], e.prototype, "helperText", 2);
|
|
87
|
+
t([
|
|
88
|
+
o({ type: String, reflect: !0 })
|
|
89
|
+
], e.prototype, "state", 2);
|
|
90
|
+
t([
|
|
91
|
+
o({ type: Boolean, reflect: !0 })
|
|
92
|
+
], e.prototype, "disabled", 2);
|
|
93
|
+
t([
|
|
94
|
+
o({ type: String, reflect: !0 })
|
|
95
|
+
], e.prototype, "theme", 2);
|
|
96
|
+
t([
|
|
97
|
+
o({ type: String })
|
|
98
|
+
], e.prototype, "trigger", 2);
|
|
99
|
+
t([
|
|
100
|
+
o({ attribute: !1 })
|
|
101
|
+
], e.prototype, "onSearch", 2);
|
|
102
|
+
e = t([
|
|
103
|
+
g("o-search-input")
|
|
104
|
+
], e);
|
|
105
|
+
export {
|
|
106
|
+
e as OccitaneSearchInput
|
|
107
|
+
};
|