@ahriknow/lux 0.0.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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +127 -0
  3. package/README_zh-CN.md +127 -0
  4. package/dist/components/lux-button/index.iife.min.js +292 -0
  5. package/dist/components/lux-button/index.min.js +292 -0
  6. package/dist/components/lux-code/index.iife.min.js +290 -0
  7. package/dist/components/lux-code/index.min.js +290 -0
  8. package/dist/components/lux-dropdown/index.iife.min.js +162 -0
  9. package/dist/components/lux-dropdown/index.min.js +162 -0
  10. package/dist/components/lux-example/index.iife.min.js +88 -0
  11. package/dist/components/lux-example/index.min.js +88 -0
  12. package/dist/components/lux-icon/index.iife.min.js +22 -0
  13. package/dist/components/lux-icon/index.min.js +22 -0
  14. package/dist/components/lux-input/index.iife.min.js +238 -0
  15. package/dist/components/lux-input/index.min.js +238 -0
  16. package/dist/components/lux-layout/index.iife.min.js +90 -0
  17. package/dist/components/lux-layout/index.min.js +90 -0
  18. package/dist/components/lux-menu/index.iife.min.js +193 -0
  19. package/dist/components/lux-menu/index.min.js +193 -0
  20. package/dist/components/lux-scroll/index.iife.min.js +137 -0
  21. package/dist/components/lux-scroll/index.min.js +137 -0
  22. package/dist/components/lux-switch/index.iife.min.js +116 -0
  23. package/dist/components/lux-switch/index.min.js +116 -0
  24. package/dist/components/lux-table/index.iife.min.js +67 -0
  25. package/dist/components/lux-table/index.min.js +67 -0
  26. package/dist/lux.core.min.js +1 -0
  27. package/dist/lux.i18n.min.js +1 -0
  28. package/dist/lux.iife.js +1822 -0
  29. package/dist/lux.iife.js.map +1 -0
  30. package/dist/lux.iife.min.js +1 -0
  31. package/dist/lux.js +1792 -0
  32. package/dist/lux.js.map +1 -0
  33. package/dist/lux.min.js +1 -0
  34. package/dist/lux.router.min.js +1 -0
  35. package/dist/lux.template.min.js +1 -0
  36. package/dist/lux.theme.min.js +1 -0
  37. package/dist/themes/dark.css +130 -0
  38. package/dist/themes/light.css +128 -0
  39. package/package.json +64 -0
  40. package/src/components/lux-button/index.js +319 -0
  41. package/src/components/lux-code/index.js +382 -0
  42. package/src/components/lux-dropdown/index.js +256 -0
  43. package/src/components/lux-example/index.js +117 -0
  44. package/src/components/lux-icon/index.js +180 -0
  45. package/src/components/lux-input/index.js +363 -0
  46. package/src/components/lux-layout/index.js +222 -0
  47. package/src/components/lux-menu/index.js +283 -0
  48. package/src/components/lux-scroll/index.js +349 -0
  49. package/src/components/lux-switch/index.js +203 -0
  50. package/src/components/lux-table/index.js +105 -0
  51. package/src/core.js +7 -0
  52. package/src/element.js +477 -0
  53. package/src/i18n/format.js +108 -0
  54. package/src/i18n/index.js +102 -0
  55. package/src/i18n/locale.js +26 -0
  56. package/src/index.js +22 -0
  57. package/src/router.js +330 -0
  58. package/src/template.js +402 -0
  59. package/src/theme/color.js +148 -0
  60. package/src/theme/create.js +97 -0
  61. package/src/theme/index.js +2 -0
  62. package/src/theme/tokens.js +128 -0
  63. package/src/themes/dark.css +130 -0
  64. package/src/themes/light.css +128 -0
@@ -0,0 +1,290 @@
1
+ const e=Symbol.for("lux-nothing");function t(e,...t){return{_$luxType$:1,strings:e,values:t}}function r(e){return e&&void 0!==e._$luxType$}const o=/(?:([@.?][\w-]+)|(ref)|(class))=\s*$/;function s(t,o,s){if(o!==e&&null!=o)if(function(e){return e&&"repeat"===e._type}(o))!function(e,t){const{items:o,keyFn:s,renderFn:i}=t,n=e._repeatState;if(n)for(const e of n.entries)e.span&&e.span.parentNode&&e.span.parentNode.removeChild(e.span);const l=document.createDocumentFragment(),c=[];for(const e of o){const t=s(e),o=i(e),n=document.createElement("span");n.style.display="contents",r(o)?a(o,n):null!=o&&!1!==o&&n.appendChild(document.createTextNode(String(o))),l.appendChild(n),c.push({key:t,result:o,span:n})}e.appendChild(l),e._repeatState={entries:c}}(t,o);else if(r(o))a(o,t);else if(Array.isArray(o)){i(t);for(const e of o)if(r(e)){const r=document.createElement("span");r.style.display="contents",a(e,r),t.appendChild(r)}else e instanceof Node?t.appendChild(e):null!=e&&!1!==e&&t.appendChild(document.createTextNode(String(e)))}else{if(o instanceof Node)return i(t),void t.appendChild(o);1===t.childNodes.length&&t.firstChild.nodeType===Node.TEXT_NODE?t.firstChild.textContent=String(o):(i(t),t.appendChild(document.createTextNode(String(o))))}else i(t)}function i(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function n(t,r){const{element:o,name:s,prefix:i}=t;switch(i){case"@":{const i=t.committedValue,n=null==r||r===e,a=n&&null!=i||r?.capture!==i?.capture||r?.once!==i?.once||r?.passive!==i?.passive,l=!n&&(null==i||a);if(a&&o.removeEventListener(s,t._handler||i,i),l)if("function"==typeof r){const e=t._host||(t._host={handleEvent(e){const r=t.committedValue;if("function"==typeof r){const t=o.getRootNode().host||o;r.call(t,e)}}});t._handler=e,o.addEventListener(s,e)}else if("object"==typeof r&&r?.handleEvent){const e={handleEvent:e=>r.handleEvent.call(r,e)};t._handler=e,o.addEventListener(s,e,{capture:r.capture,once:r.once,passive:r.passive})}t.committedValue=r;break}case".":o[s]=r===e?void 0:r;break;case"?":o.toggleAttribute(s,!!r);break;case"ref":"function"==typeof r&&r(o);break;case"class":if("string"==typeof r)o.className=r;else if("object"==typeof r&&null!=r){const e=o.className||"",t=e?e.split(/\s+/):[];for(const[e,o]of Object.entries(r))if(o)t.includes(e)||t.push(e);else{const r=t.indexOf(e);-1!==r&&t.splice(r,1)}o.className=t.filter(Boolean).join(" ")}break;default:null==r||!1===r?o.removeAttribute(s):o.setAttribute(s,!0===r?"":String(r))}}function a(e,t,i){if(!r(e))return void(t.textContent=e??"");const{strings:a,values:l}=e;if(t._luxActiveParts&&t._luxStrings===a){for(const e of t._luxActiveParts)e.index<l.length&&("child"===e.type?s(e.span,l[e.index]):n(e,l[e.index]));return}const c=document.createElement("template"),d=function(e){const t=[];let r="";for(let s=0;s<e.length;s++)if(r+=e[s],s<e.length-1){const e=r.match(o);if(e){const o=e[1],i=!!e[2],n=!!e[3];let a="",l="";o?(a=o[0],l=o.slice(1)):i?(a="ref",l="ref"):n&&(a="class",l="class");const c=`lux-attr-${s}`;r=r.slice(0,-e[0].length)+`${c}="${l}" `,t.push({type:"attr",name:l,prefix:a,marker:c,index:s})}else{const e=`lux-${s}`;r+=`\x3c!--${e}--\x3e`,t.push({type:"child",marker:e,index:s})}}return{html:r,parts:t}}(a);c.innerHTML=d.html;const h=c.content.cloneNode(!0),p=[];for(const e of d.parts)if("child"===e.type){const t=document.createTreeWalker(h,NodeFilter.SHOW_COMMENT);let r;for(;r=t.nextNode();)if(r.data===e.marker){const t=document.createElement("span");t.style.display="contents",r.parentNode.replaceChild(t,r),s(t,l[e.index]),p.push({type:"child",span:t,index:e.index});break}}else{const t=h.querySelector(`[${e.marker}]`);if(t){t.removeAttribute(e.marker);const r={type:"attr",element:t,name:e.name,prefix:e.prefix,index:e.index,committedValue:void 0};n(r,l[e.index]),p.push(r)}}t.textContent="",t.appendChild(h),t._luxActiveParts=p,t._luxStrings=a}const l=new Set;let c=!1;function d(e){var t;l.add(e),c||(c=!0,t=()=>{c=!1;const e=[...l];l.clear();for(const t of e)t._$performUpdate()},Promise.resolve().then(t))}const h={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?null:JSON.stringify(e);default:return e}},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return Number(e);case Object:case Array:try{return JSON.parse(e)}catch{return null}default:return e}}};class p extends HTMLElement{static properties={};static styles=void 0;static finalized=!1;static elementProperties=new Map;static __prepare(){if(this.hasOwnProperty("elementProperties"))return;const e=Object.getPrototypeOf(this);e.finalize&&e.finalize(),this.elementProperties=new Map(e.elementProperties)}static get observedAttributes(){return this.finalize(),this.__attributeToPropertyMap?[...this.__attributeToPropertyMap.keys()]:[]}static finalize(){if(!this.hasOwnProperty("finalized")){if(this.finalized=!0,this.__prepare(),this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const r of t)this.createProperty(r,e[r])}this.__attributeToPropertyMap=new Map;for(const[e,t]of this.elementProperties){const r=this.__attributeNameForProperty(e,t);void 0!==r&&this.__attributeToPropertyMap.set(r,e)}this.elementStyles=this.styles}}static __attributeNameForProperty(e,t){const r=t.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof e?e.replace(/([A-Z])/g,"-$1").toLowerCase():void 0}static createProperty(e,t={}){if(this.__prepare(),!this.elementProperties.has(e)&&(t.state&&(t={...t,attribute:!1}),this.elementProperties.set(e,t),!t.noAccessor)){const r=Symbol(),o=this.getPropertyDescriptor(e,r,t);void 0!==o&&Object.defineProperty(this.prototype,e,o)}}static getPropertyDescriptor(e,t,r){const{type:o,reflect:s,converter:i}=r;return{get(){return this[t]},set(o){const s=this[t];this[t]=o,this.requestUpdate(e,s,r)},configurable:!0,enumerable:!0}}static _initializers=[];static addInitializer(e){this._initializers=[...this._initializers||[],e]}static shadowRootOptions={mode:"open"};constructor(){super(),this.__updatePending=!1,this.__hasUpdated=!1,this.__controllers=new Set,this.__reflectingProperty=null,this.constructor.hasOwnProperty("finalized")||this.constructor.finalize(),this.__saveInstanceProperties(),this.requestUpdate();for(const e of this.constructor._initializers||[])e(this)}__saveInstanceProperties(){const e=this.constructor.elementProperties;if(e)for(const[t,r]of e)if(!r.noAccessor&&this.hasOwnProperty(t)){const e=this[t];delete this[t],this.__instancePropertyValues=this.__instancePropertyValues||new Map,this.__instancePropertyValues.set(t,e)}}connectedCallback(){this.__controllers.forEach(e=>e.hostConnected?.()),this.constructor.hasOwnProperty("finalized")||this.constructor.finalize();const e=this.constructor.__attributeToPropertyMap;if(e)for(const[t,r]of e){const e=this.getAttribute(t);if(null!==e){const t=this.constructor.elementProperties.get(r);if(t){const o=t.converter?.fromAttribute??h.fromAttribute;this[r]=o(e,t.type)}}}if(this.__instancePropertyValues){for(const[e,t]of this.__instancePropertyValues)this[e]=t;this.__instancePropertyValues=void 0}this.renderRoot,this.__hasUpdated||this.requestUpdate()}disconnectedCallback(){this.__controllers.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,r){const o=this.constructor.__attributeToPropertyMap?.get(e);if(void 0!==o&&this.__reflectingProperty!==o){const e=this.constructor.elementProperties.get(o);if(e){const t="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:h;this.__reflectingProperty=o;const s=t.fromAttribute(r,e.type);this[o]=s,this.__reflectingProperty=null}}}get renderRoot(){return this._renderRoot||(this._renderRoot=this.createRenderRoot(),this.__adoptStyles()),this._renderRoot}createRenderRoot(){return this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions)}__adoptStyles(){const e=this.constructor.elementStyles;if(!e)return;const t=Array.isArray(e)?e:[e],o=[];for(const e of t)"string"==typeof e?o.push(e):r(e)&&o.push(e.strings.join(""));if(0!==o.length)if(void 0!==this._renderRoot.adoptedStyleSheets){const e=new CSSStyleSheet;e.replaceSync(o.join("\n")),this._renderRoot.adoptedStyleSheets=[...this._renderRoot.adoptedStyleSheets,e]}else{const e=document.createElement("style");e.textContent=o.join("\n"),this._renderRoot.appendChild(e)}}enableUpdating(e){}get updateComplete(){return this.__updateCompletePromise??Promise.resolve()}get hasUpdated(){return this.__hasUpdated}get isUpdatePending(){return this.__updatePending}requestUpdate(e,t,r){if(void 0!==e){if(!(r?.hasChanged??((e,t)=>!Object.is(e,t)))(this[e],t))return}this.__updatePending||(this.__updatePending=!0,d(this))}async performUpdate(){if(this.isUpdatePending){this.__updatePending=!1,this.willUpdate(new Map),this.__controllers.forEach(e=>e.hostUpdate?.()),this.update(new Map),this.__hasUpdated=!0;for(const[e,t]of this.constructor.elementProperties)if(t.reflect){const r=this[e],o=t.converter?.toAttribute??h.toAttribute,s=this.constructor.__attributeNameForProperty(e,t);if(void 0!==s){this.__reflectingProperty=e;const i=o(r,t.type);null==i?this.removeAttribute(s):this.setAttribute(s,String(i)),this.__reflectingProperty=null}}this.__controllers.forEach(e=>e.hostUpdated?.()),this.firstUpdated(new Map),this.updated(new Map)}}_$performUpdate(){this.performUpdate()}shouldUpdate(e){return!0}willUpdate(e){}update(e){const t=this.render();t&&a(t,this.renderRoot)}render(){return t``}firstUpdated(e){}updated(e){}propertyChangedCallback(e,t,r){}addController(e){this.__controllers.add(e),this.isConnected&&e.hostConnected?.()}removeController(e){this.__controllers.delete(e)}emit(e,t,r={}){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0,...r}))}$(e){return this.renderRoot.querySelector(e)}$$(e){return this.renderRoot.querySelectorAll(e)}}const u=(function(e,...t){return{_$luxType$:3,strings:e,values:t}})`
2
+ :host {
3
+ display: block;
4
+ position: relative;
5
+ margin: 12px 0;
6
+ border-radius: var(--lux-radius, 6px);
7
+ border: 1px solid rgb(var(--lux-code-border, 226 232 240));
8
+ }
9
+
10
+ :host(.has-fixed-height) {
11
+ display: flex;
12
+ flex-direction: column;
13
+ }
14
+
15
+ :host(.has-fixed-height) .code-body {
16
+ flex: 1;
17
+ min-height: 0;
18
+ overflow: auto;
19
+ display: flex;
20
+ flex-direction: column;
21
+ }
22
+
23
+ :host(.has-fixed-height) pre {
24
+ flex: 1;
25
+ min-height: 0;
26
+ }
27
+
28
+ /* ── Header ── */
29
+ .header {
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: space-between;
33
+ padding: 4px 14px;
34
+ background: rgb(var(--lux-code-header, 241 245 249));
35
+ border-bottom: 1px solid rgb(var(--lux-code-border, 226 232 240));
36
+ font-size: 12px;
37
+ color: rgb(var(--lux-text-muted, 100 116 139));
38
+ }
39
+ .header.hidden {
40
+ display: none;
41
+ }
42
+
43
+ .dots {
44
+ display: flex;
45
+ gap: 8px;
46
+ }
47
+ .dot {
48
+ width: 12px;
49
+ height: 12px;
50
+ border-radius: 50%;
51
+ }
52
+ .dot-red {
53
+ background: #ff5f57;
54
+ }
55
+ .dot-yellow {
56
+ background: #ffbd2e;
57
+ }
58
+ .dot-green {
59
+ background: #28c840;
60
+ }
61
+
62
+ .header-right {
63
+ display: flex;
64
+ align-items: center;
65
+ gap: 8px;
66
+ }
67
+
68
+ .lang-label {
69
+ font-size: 11px;
70
+ color: rgb(var(--lux-text-muted, 100 116 139));
71
+ opacity: 0.7;
72
+ }
73
+
74
+ .copy-btn {
75
+ display: inline-flex;
76
+ align-items: center;
77
+ justify-content: center;
78
+ padding: 4px;
79
+ border: none;
80
+ border-radius: 4px;
81
+ background: transparent;
82
+ color: rgb(var(--lux-text-secondary, 148 163 184));
83
+ cursor: pointer;
84
+ transition: all 0.15s;
85
+ }
86
+ .copy-btn:hover {
87
+ background: rgb(var(--lux-hover, 0 0 0 / 5%));
88
+ color: rgb(var(--lux-text, 15 23 42));
89
+ }
90
+
91
+ /* ── Floating copy (no header) ── */
92
+ .copy-float {
93
+ position: absolute;
94
+ top: 8px;
95
+ right: 8px;
96
+ display: none;
97
+ align-items: center;
98
+ justify-content: center;
99
+ width: 32px;
100
+ height: 32px;
101
+ border-radius: 6px;
102
+ background: rgb(var(--lux-code-header, 241 245 249));
103
+ border: 1px solid rgb(var(--lux-code-border, 226 232 240));
104
+ color: rgb(var(--lux-text-secondary, 148 163 184));
105
+ cursor: pointer;
106
+ transition: all 0.15s;
107
+ z-index: 1;
108
+ }
109
+ .copy-float:hover {
110
+ background: rgb(var(--lux-hover, 0 0 0 / 5%));
111
+ color: rgb(var(--lux-text, 15 23 42));
112
+ }
113
+ :host(:not([show-header]):hover) .copy-float {
114
+ display: flex;
115
+ }
116
+
117
+ /* ── Code block ── */
118
+ .code-body {
119
+ padding: 14px 18px;
120
+ position: relative;
121
+ background: rgb(var(--lux-code-bg, 248 250 252));
122
+ border-radius: 0 0 var(--lux-radius, 6px) var(--lux-radius, 6px);
123
+ overflow: auto;
124
+ }
125
+ :host([show-header]) .code-body {
126
+ border-radius: 0;
127
+ }
128
+
129
+ pre {
130
+ margin: 0;
131
+ padding: 0;
132
+ font-size: 13px;
133
+ line-height: 1.7;
134
+ font-family: var(--lux-font-mono, 'SF Mono', Consolas, monospace);
135
+ color: rgb(var(--lux-code-text, 51 65 85));
136
+ }
137
+
138
+ pre code {
139
+ display: block;
140
+ padding: 0;
141
+ }
142
+
143
+ .code-body::-webkit-scrollbar {
144
+ width: 8px;
145
+ height: 8px;
146
+ }
147
+ .code-body::-webkit-scrollbar-track {
148
+ background: transparent;
149
+ }
150
+ .code-body::-webkit-scrollbar-thumb {
151
+ background: rgb(var(--lux-scrollbar, 180 196 214));
152
+ border-radius: 4px;
153
+ }
154
+ .code-body::-webkit-scrollbar-thumb:hover {
155
+ background: rgb(var(--lux-text-muted, 100 116 139));
156
+ }
157
+ .code-body {
158
+ scrollbar-width: thin;
159
+ scrollbar-color: rgb(var(--lux-scrollbar, 180 196 214)) transparent;
160
+ }
161
+
162
+ pre code {
163
+ display: block;
164
+ font-family: inherit;
165
+ font-size: inherit;
166
+ line-height: inherit;
167
+ background: transparent;
168
+ padding: 0;
169
+ white-space: pre;
170
+ }
171
+
172
+ /* ── highlight.js token styles via CSS variables ── */
173
+ .hljs-keyword,
174
+ .hljs-doctag,
175
+ .hljs-template-tag,
176
+ .hljs-template-variable,
177
+ .hljs-type,
178
+ .hljs-variable.language_ {
179
+ color: rgb(var(--lux-code-keyword));
180
+ }
181
+ .hljs-string,
182
+ .hljs-meta .hljs-string,
183
+ .hljs-regexp {
184
+ color: rgb(var(--lux-code-string));
185
+ }
186
+ .hljs-number,
187
+ .hljs-literal,
188
+ .hljs-attr,
189
+ .hljs-attribute,
190
+ .hljs-selector-attr,
191
+ .hljs-selector-class,
192
+ .hljs-selector-id,
193
+ .hljs-variable {
194
+ color: rgb(var(--lux-code-number));
195
+ }
196
+ .hljs-comment,
197
+ .hljs-quote,
198
+ .hljs-formula,
199
+ .hljs-code {
200
+ color: rgb(var(--lux-code-comment));
201
+ font-style: italic;
202
+ }
203
+ .hljs-title.class_,
204
+ .hljs-title.class_.inherited__ {
205
+ color: rgb(var(--lux-code-class));
206
+ }
207
+ .hljs-title.function_ {
208
+ color: rgb(var(--lux-code-function));
209
+ }
210
+ .hljs-variable {
211
+ color: rgb(var(--lux-code-variable));
212
+ }
213
+ .hljs-tag,
214
+ .hljs-name,
215
+ .hljs-selector-pseudo,
216
+ .hljs-selector-tag {
217
+ color: rgb(var(--lux-code-tag));
218
+ }
219
+ .hljs-attr {
220
+ color: rgb(var(--lux-code-attr));
221
+ }
222
+ .hljs-selector-class {
223
+ color: rgb(var(--lux-code-selector));
224
+ }
225
+ .hljs-literal {
226
+ color: rgb(var(--lux-code-literal));
227
+ }
228
+ .hljs-symbol {
229
+ color: rgb(var(--lux-code-symbol));
230
+ }
231
+ .hljs-built_in {
232
+ color: rgb(var(--lux-code-built-in));
233
+ }
234
+ .hljs-meta {
235
+ color: rgb(var(--lux-code-meta));
236
+ }
237
+ .hljs-section {
238
+ color: rgb(var(--lux-code-section));
239
+ font-weight: 700;
240
+ }
241
+ .hljs-bullet {
242
+ color: rgb(var(--lux-code-bullet));
243
+ }
244
+ .hljs-operator {
245
+ color: rgb(var(--lux-code-operator));
246
+ }
247
+ .hljs-punctuation {
248
+ color: rgb(var(--lux-code-punctuation));
249
+ }
250
+ .hljs-subst {
251
+ color: rgb(var(--lux-code-text));
252
+ }
253
+ .hljs-addition {
254
+ color: rgb(var(--lux-code-addition));
255
+ }
256
+ .hljs-deletion {
257
+ color: rgb(var(--lux-code-deletion));
258
+ }
259
+ .hljs-emphasis {
260
+ font-style: italic;
261
+ }
262
+ .hljs-strong {
263
+ font-weight: 700;
264
+ }
265
+
266
+ .copied {
267
+ color: rgb(var(--lux-success, 34 197 94)) !important;
268
+ }
269
+ `,f=t`<span class="icon-svg" style="width:14px;height:14px;fill:currentColor"
270
+ ><svg viewBox="0 0 24 24">
271
+ <path
272
+ d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"
273
+ /></svg
274
+ ></span>`;class g extends p{static styles=u;static properties={code:{type:String},language:{type:String,reflect:!0},showHeader:{type:Boolean,attribute:"show-header",reflect:!0},showLanguage:{type:Boolean,attribute:"show-language",reflect:!0},showCopy:{type:Boolean,attribute:"show-copy",reflect:!0}};constructor(){super(),this.code=this.code||"",this.language=this.language||"",this.showHeader=this.showHeader??!1,this.showLanguage=this.showLanguage??!0,this.showCopy=this.showCopy??!0}updated(){this._highlight(),this._checkHeight()}_checkHeight(){const e=this.shadowRoot.host,t=e.getAttribute("style")||"",r=/height\s*:/i.test(t);e.classList.toggle("has-fixed-height",r)}_highlight(){const e=this.renderRoot.querySelector("code");if(!e||!this.code)return;e.textContent=this.code;const t=window.hljs;if(t){const r=String(this.language||"");r&&(e.className=`language-${r}`);try{t.highlightElement(e)}catch(e){}}}async _copy(){try{await navigator.clipboard.writeText(this.code);this.renderRoot.querySelectorAll(".copy-btn, .copy-float").forEach(e=>{e.classList.add("copied"),setTimeout(()=>e.classList.remove("copied"),2e3)}),this.emit("copy",{code:this.code})}catch{}}render(){return t`
275
+ <div class=${{header:!0,hidden:!this.showHeader}}>
276
+ <div class="dots">
277
+ <span class="dot dot-red"></span>
278
+ <span class="dot dot-yellow"></span>
279
+ <span class="dot dot-green"></span>
280
+ </div>
281
+ <div class="header-right">
282
+ ${this.showLanguage?t`<span class="lang-label">${this.language||"text"}</span>`:""}
283
+ ${this.showCopy?t`<button class="copy-btn" @click=${()=>this._copy()}>${f}</button>`:""}
284
+ </div>
285
+ </div>
286
+ ${!this.showHeader&&this.showCopy?t`<button class="copy-float" @click=${()=>this._copy()}>${f}</button>`:""}
287
+ <div class="code-body">
288
+ <pre><code></code></pre>
289
+ </div>
290
+ `}}!function(e,t){if(!e.includes("-"))throw new Error(`Component name must contain a hyphen: ${e}`);customElements.get(e)||customElements.define(e,t)}("lux-code",g);export{g as default};
@@ -0,0 +1,162 @@
1
+ var LuxDropdown=function(){"use strict";const e=Symbol.for("lux-nothing");function t(e,...t){return{_$luxType$:1,strings:e,values:t}}function r(e){return e&&void 0!==e._$luxType$}const s=/(?:([@.?][\w-]+)|(ref)|(class))=\s*$/;function i(t,s,i){if(s!==e&&null!=s)if(function(e){return e&&"repeat"===e._type}(s))!function(e,t){const{items:s,keyFn:i,renderFn:n}=t,o=e._repeatState;if(o)for(const e of o.entries)e.span&&e.span.parentNode&&e.span.parentNode.removeChild(e.span);const l=document.createDocumentFragment(),c=[];for(const e of s){const t=i(e),s=n(e),o=document.createElement("span");o.style.display="contents",r(s)?a(s,o):null!=s&&!1!==s&&o.appendChild(document.createTextNode(String(s))),l.appendChild(o),c.push({key:t,result:s,span:o})}e.appendChild(l),e._repeatState={entries:c}}(t,s);else if(r(s))a(s,t);else if(Array.isArray(s)){n(t);for(const e of s)if(r(e)){const r=document.createElement("span");r.style.display="contents",a(e,r),t.appendChild(r)}else e instanceof Node?t.appendChild(e):null!=e&&!1!==e&&t.appendChild(document.createTextNode(String(e)))}else{if(s instanceof Node)return n(t),void t.appendChild(s);1===t.childNodes.length&&t.firstChild.nodeType===Node.TEXT_NODE?t.firstChild.textContent=String(s):(n(t),t.appendChild(document.createTextNode(String(s))))}else n(t)}function n(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function o(t,r){const{element:s,name:i,prefix:n}=t;switch(n){case"@":{const n=t.committedValue,o=null==r||r===e,a=o&&null!=n||r?.capture!==n?.capture||r?.once!==n?.once||r?.passive!==n?.passive,l=!o&&(null==n||a);if(a&&s.removeEventListener(i,t._handler||n,n),l)if("function"==typeof r){const e=t._host||(t._host={handleEvent(e){const r=t.committedValue;if("function"==typeof r){const t=s.getRootNode().host||s;r.call(t,e)}}});t._handler=e,s.addEventListener(i,e)}else if("object"==typeof r&&r?.handleEvent){const e={handleEvent:e=>r.handleEvent.call(r,e)};t._handler=e,s.addEventListener(i,e,{capture:r.capture,once:r.once,passive:r.passive})}t.committedValue=r;break}case".":s[i]=r===e?void 0:r;break;case"?":s.toggleAttribute(i,!!r);break;case"ref":"function"==typeof r&&r(s);break;case"class":if("string"==typeof r)s.className=r;else if("object"==typeof r&&null!=r){const e=s.className||"",t=e?e.split(/\s+/):[];for(const[e,s]of Object.entries(r))if(s)t.includes(e)||t.push(e);else{const r=t.indexOf(e);-1!==r&&t.splice(r,1)}s.className=t.filter(Boolean).join(" ")}break;default:null==r||!1===r?s.removeAttribute(i):s.setAttribute(i,!0===r?"":String(r))}}function a(e,t,n){if(!r(e))return void(t.textContent=e??"");const{strings:a,values:l}=e;if(t._luxActiveParts&&t._luxStrings===a){for(const e of t._luxActiveParts)e.index<l.length&&("child"===e.type?i(e.span,l[e.index]):o(e,l[e.index]));return}const c=document.createElement("template"),p=function(e){const t=[];let r="";for(let i=0;i<e.length;i++)if(r+=e[i],i<e.length-1){const e=r.match(s);if(e){const s=e[1],n=!!e[2],o=!!e[3];let a="",l="";s?(a=s[0],l=s.slice(1)):n?(a="ref",l="ref"):o&&(a="class",l="class");const c=`lux-attr-${i}`;r=r.slice(0,-e[0].length)+`${c}="${l}" `,t.push({type:"attr",name:l,prefix:a,marker:c,index:i})}else{const e=`lux-${i}`;r+=`\x3c!--${e}--\x3e`,t.push({type:"child",marker:e,index:i})}}return{html:r,parts:t}}(a);c.innerHTML=p.html;const d=c.content.cloneNode(!0),h=[];for(const e of p.parts)if("child"===e.type){const t=document.createTreeWalker(d,NodeFilter.SHOW_COMMENT);let r;for(;r=t.nextNode();)if(r.data===e.marker){const t=document.createElement("span");t.style.display="contents",r.parentNode.replaceChild(t,r),i(t,l[e.index]),h.push({type:"child",span:t,index:e.index});break}}else{const t=d.querySelector(`[${e.marker}]`);if(t){t.removeAttribute(e.marker);const r={type:"attr",element:t,name:e.name,prefix:e.prefix,index:e.index,committedValue:void 0};o(r,l[e.index]),h.push(r)}}t.textContent="",t.appendChild(d),t._luxActiveParts=h,t._luxStrings=a}const l=new Set;let c=!1;function p(e){var t;l.add(e),c||(c=!0,t=()=>{c=!1;const e=[...l];l.clear();for(const t of e)t._$performUpdate()},Promise.resolve().then(t))}const d={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?null:JSON.stringify(e);default:return e}},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return Number(e);case Object:case Array:try{return JSON.parse(e)}catch{return null}default:return e}}};class h extends HTMLElement{static properties={};static styles=void 0;static finalized=!1;static elementProperties=new Map;static __prepare(){if(this.hasOwnProperty("elementProperties"))return;const e=Object.getPrototypeOf(this);e.finalize&&e.finalize(),this.elementProperties=new Map(e.elementProperties)}static get observedAttributes(){return this.finalize(),this.__attributeToPropertyMap?[...this.__attributeToPropertyMap.keys()]:[]}static finalize(){if(!this.hasOwnProperty("finalized")){if(this.finalized=!0,this.__prepare(),this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const r of t)this.createProperty(r,e[r])}this.__attributeToPropertyMap=new Map;for(const[e,t]of this.elementProperties){const r=this.__attributeNameForProperty(e,t);void 0!==r&&this.__attributeToPropertyMap.set(r,e)}this.elementStyles=this.styles}}static __attributeNameForProperty(e,t){const r=t.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof e?e.replace(/([A-Z])/g,"-$1").toLowerCase():void 0}static createProperty(e,t={}){if(this.__prepare(),!this.elementProperties.has(e)&&(t.state&&(t={...t,attribute:!1}),this.elementProperties.set(e,t),!t.noAccessor)){const r=Symbol(),s=this.getPropertyDescriptor(e,r,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,r){const{type:s,reflect:i,converter:n}=r;return{get(){return this[t]},set(s){const i=this[t];this[t]=s,this.requestUpdate(e,i,r)},configurable:!0,enumerable:!0}}static _initializers=[];static addInitializer(e){this._initializers=[...this._initializers||[],e]}static shadowRootOptions={mode:"open"};constructor(){super(),this.__updatePending=!1,this.__hasUpdated=!1,this.__controllers=new Set,this.__reflectingProperty=null,this.constructor.hasOwnProperty("finalized")||this.constructor.finalize(),this.__saveInstanceProperties(),this.requestUpdate();for(const e of this.constructor._initializers||[])e(this)}__saveInstanceProperties(){const e=this.constructor.elementProperties;if(e)for(const[t,r]of e)if(!r.noAccessor&&this.hasOwnProperty(t)){const e=this[t];delete this[t],this.__instancePropertyValues=this.__instancePropertyValues||new Map,this.__instancePropertyValues.set(t,e)}}connectedCallback(){this.__controllers.forEach(e=>e.hostConnected?.()),this.constructor.hasOwnProperty("finalized")||this.constructor.finalize();const e=this.constructor.__attributeToPropertyMap;if(e)for(const[t,r]of e){const e=this.getAttribute(t);if(null!==e){const t=this.constructor.elementProperties.get(r);if(t){const s=t.converter?.fromAttribute??d.fromAttribute;this[r]=s(e,t.type)}}}if(this.__instancePropertyValues){for(const[e,t]of this.__instancePropertyValues)this[e]=t;this.__instancePropertyValues=void 0}this.renderRoot,this.__hasUpdated||this.requestUpdate()}disconnectedCallback(){this.__controllers.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,r){const s=this.constructor.__attributeToPropertyMap?.get(e);if(void 0!==s&&this.__reflectingProperty!==s){const e=this.constructor.elementProperties.get(s);if(e){const t="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:d;this.__reflectingProperty=s;const i=t.fromAttribute(r,e.type);this[s]=i,this.__reflectingProperty=null}}}get renderRoot(){return this._renderRoot||(this._renderRoot=this.createRenderRoot(),this.__adoptStyles()),this._renderRoot}createRenderRoot(){return this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions)}__adoptStyles(){const e=this.constructor.elementStyles;if(!e)return;const t=Array.isArray(e)?e:[e],s=[];for(const e of t)"string"==typeof e?s.push(e):r(e)&&s.push(e.strings.join(""));if(0!==s.length)if(void 0!==this._renderRoot.adoptedStyleSheets){const e=new CSSStyleSheet;e.replaceSync(s.join("\n")),this._renderRoot.adoptedStyleSheets=[...this._renderRoot.adoptedStyleSheets,e]}else{const e=document.createElement("style");e.textContent=s.join("\n"),this._renderRoot.appendChild(e)}}enableUpdating(e){}get updateComplete(){return this.__updateCompletePromise??Promise.resolve()}get hasUpdated(){return this.__hasUpdated}get isUpdatePending(){return this.__updatePending}requestUpdate(e,t,r){if(void 0!==e){if(!(r?.hasChanged??((e,t)=>!Object.is(e,t)))(this[e],t))return}this.__updatePending||(this.__updatePending=!0,p(this))}async performUpdate(){if(this.isUpdatePending){this.__updatePending=!1,this.willUpdate(new Map),this.__controllers.forEach(e=>e.hostUpdate?.()),this.update(new Map),this.__hasUpdated=!0;for(const[e,t]of this.constructor.elementProperties)if(t.reflect){const r=this[e],s=t.converter?.toAttribute??d.toAttribute,i=this.constructor.__attributeNameForProperty(e,t);if(void 0!==i){this.__reflectingProperty=e;const n=s(r,t.type);null==n?this.removeAttribute(i):this.setAttribute(i,String(n)),this.__reflectingProperty=null}}this.__controllers.forEach(e=>e.hostUpdated?.()),this.firstUpdated(new Map),this.updated(new Map)}}_$performUpdate(){this.performUpdate()}shouldUpdate(e){return!0}willUpdate(e){}update(e){const t=this.render();t&&a(t,this.renderRoot)}render(){return t``}firstUpdated(e){}updated(e){}propertyChangedCallback(e,t,r){}addController(e){this.__controllers.add(e),this.isConnected&&e.hostConnected?.()}removeController(e){this.__controllers.delete(e)}emit(e,t,r={}){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0,...r}))}$(e){return this.renderRoot.querySelector(e)}$$(e){return this.renderRoot.querySelectorAll(e)}}const u=t`<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor">
2
+ <path d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6z" />
3
+ </svg>`,f=t`<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor">
4
+ <path
5
+ d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
6
+ />
7
+ </svg>`,m=(function(e,...t){return{_$luxType$:3,strings:e,values:t}})`
8
+ :host {
9
+ display: inline-block;
10
+ position: relative;
11
+ }
12
+ .trigger {
13
+ display: flex;
14
+ align-items: center;
15
+ gap: 6px;
16
+ width: 100%;
17
+ padding: 6px 12px;
18
+ border: 1px solid rgb(var(--lux-border, 51 65 85));
19
+ border-radius: var(--lux-radius, 6px);
20
+ background: rgb(var(--lux-card, 30 41 59));
21
+ color: rgb(var(--lux-text, 241 245 249));
22
+ font-size: 13px;
23
+ cursor: pointer;
24
+ user-select: none;
25
+ white-space: nowrap;
26
+ box-sizing: border-box;
27
+ }
28
+ .trigger:hover {
29
+ border-color: rgb(var(--lux-primary-500, 99 91 218));
30
+ background: rgb(var(--lux-hover, 255 255 255 / 5%));
31
+ }
32
+ .placeholder {
33
+ color: rgb(var(--lux-text-muted, 100 116 139));
34
+ }
35
+ .end-icons {
36
+ display: inline-flex;
37
+ align-items: center;
38
+ justify-content: center;
39
+ position: relative;
40
+ width: 18px;
41
+ height: 18px;
42
+ flex-shrink: 0;
43
+ margin-left: auto;
44
+ }
45
+ .arrow,
46
+ .clear {
47
+ display: inline-flex;
48
+ align-items: center;
49
+ justify-content: center;
50
+ position: absolute;
51
+ top: 0;
52
+ left: 0;
53
+ width: 18px;
54
+ height: 18px;
55
+ transition: opacity 150ms ease;
56
+ }
57
+ .arrow {
58
+ color: rgb(var(--lux-text-secondary, 148 163 184));
59
+ transition:
60
+ transform 150ms ease,
61
+ opacity 150ms ease;
62
+ }
63
+ :host([open]) .arrow {
64
+ transform: rotate(180deg);
65
+ }
66
+ .clear {
67
+ display: none;
68
+ cursor: pointer;
69
+ color: rgb(var(--lux-text-secondary, 148 163 184));
70
+ z-index: 1;
71
+ }
72
+ .clear:hover {
73
+ color: rgb(var(--lux-text, 241 245 249));
74
+ }
75
+ :host([clearable][has-value]:hover) .clear {
76
+ display: inline-flex;
77
+ }
78
+ :host([clearable][has-value]:hover) .arrow {
79
+ opacity: 0;
80
+ pointer-events: none;
81
+ }
82
+ .menu {
83
+ position: absolute;
84
+ top: calc(100% + 4px);
85
+ left: 0;
86
+ min-width: 100%;
87
+ max-height: 200px;
88
+ overflow-y: auto;
89
+ background: rgb(var(--lux-card, 30 41 59));
90
+ border: 1px solid rgb(var(--lux-border, 51 65 85));
91
+ border-radius: var(--lux-radius, 6px);
92
+ box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
93
+ z-index: 1000;
94
+ padding: 4px 0;
95
+ display: none;
96
+ }
97
+ :host([open]) .menu {
98
+ display: block;
99
+ }
100
+ .item {
101
+ display: block;
102
+ padding: 7px 12px;
103
+ font-size: 13px;
104
+ color: rgb(var(--lux-text, 241 245 249));
105
+ cursor: pointer;
106
+ white-space: nowrap;
107
+ user-select: none;
108
+ }
109
+ .item:hover {
110
+ background: rgb(var(--lux-hover, 255 255 255 / 5%));
111
+ }
112
+ .item.active {
113
+ color: rgb(var(--lux-primary-400, 129 113 234));
114
+ }
115
+
116
+ /* Size: sm */
117
+ :host([size='sm']) .trigger {
118
+ padding: 4px 8px;
119
+ font-size: 12px;
120
+ gap: 4px;
121
+ }
122
+ :host([size='sm']) .item {
123
+ padding: 5px 10px;
124
+ font-size: 12px;
125
+ }
126
+ :host([size='sm']) .end-icons {
127
+ width: 14px;
128
+ height: 14px;
129
+ }
130
+
131
+ /* Size: lg */
132
+ :host([size='lg']) .trigger {
133
+ padding: 10px 16px;
134
+ font-size: 15px;
135
+ gap: 8px;
136
+ }
137
+ :host([size='lg']) .item {
138
+ padding: 10px 16px;
139
+ font-size: 15px;
140
+ }
141
+ :host([size='lg']) .end-icons {
142
+ width: 22px;
143
+ height: 22px;
144
+ }
145
+ `;class _ extends h{static styles=m;static properties={options:{type:Array,attribute:!1},value:{type:String,reflect:!0},placeholder:{type:String,reflect:!0},open:{type:Boolean,reflect:!0},clearable:{type:Boolean,reflect:!0},size:{type:String,reflect:!0}};constructor(){super(),this.placeholder="",this.value="",this.clearable=!1,this._onDocClickBound=!1}connectedCallback(){super.connectedCallback(),this._bindDocClick()}_bindDocClick(){this._onDocClickBound||(this._onDocClick=this._onDocClick.bind(this),document.addEventListener("click",this._onDocClick,!0),this._onDocClickBound=!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._onDocClick,!0),this._onDocClickBound=!1}updated(){this.value?this.setAttribute("has-value",""):this.removeAttribute("has-value")}_onDocClick(e){this.contains(e.target)||(this.open=!1)}_toggle(){this.open=!this.open}_clear(){this.value="",this.emit("clear")}_select(e){this.value=String(e.value),this.open=!1,this.emit("change",{value:e.value,label:e.label??e.value})}render(){const e=Array.isArray(this.options)?this.options:[],r=e.find(e=>String(e.value)===String(this.value)),s=r?r.label??r.value:"",i=this.placeholder;return t`
146
+ <div class="trigger" @click=${()=>this._toggle()}>
147
+ <span class=${{placeholder:!s&&!!i}}>${s||i}</span>
148
+ <span class="end-icons">
149
+ <span
150
+ class=${{clear:!0}}
151
+ @click=${e=>{e.stopPropagation(),this._clear()}}
152
+ >${f}</span
153
+ >
154
+ <span class="arrow">${u}</span>
155
+ </span>
156
+ </div>
157
+ <div class="menu">
158
+ ${n=e,o=e=>e.value,a=e=>t`
159
+ <div class="item" @click=${()=>this._select(e)}>${e.label??e.value}</div>
160
+ `,{_type:"repeat",items:n,keyFn:o,renderFn:a}}
161
+ </div>
162
+ `;var n,o,a}}return function(e,t){if(!e.includes("-"))throw new Error(`Component name must contain a hyphen: ${e}`);customElements.get(e)||customElements.define(e,t)}("lux-dropdown",_),_}();
@@ -0,0 +1,162 @@
1
+ const e=Symbol.for("lux-nothing");function t(e,...t){return{_$luxType$:1,strings:e,values:t}}function r(e){return e&&void 0!==e._$luxType$}const s=/(?:([@.?][\w-]+)|(ref)|(class))=\s*$/;function i(t,s,i){if(s!==e&&null!=s)if(function(e){return e&&"repeat"===e._type}(s))!function(e,t){const{items:s,keyFn:i,renderFn:o}=t,n=e._repeatState;if(n)for(const e of n.entries)e.span&&e.span.parentNode&&e.span.parentNode.removeChild(e.span);const l=document.createDocumentFragment(),c=[];for(const e of s){const t=i(e),s=o(e),n=document.createElement("span");n.style.display="contents",r(s)?a(s,n):null!=s&&!1!==s&&n.appendChild(document.createTextNode(String(s))),l.appendChild(n),c.push({key:t,result:s,span:n})}e.appendChild(l),e._repeatState={entries:c}}(t,s);else if(r(s))a(s,t);else if(Array.isArray(s)){o(t);for(const e of s)if(r(e)){const r=document.createElement("span");r.style.display="contents",a(e,r),t.appendChild(r)}else e instanceof Node?t.appendChild(e):null!=e&&!1!==e&&t.appendChild(document.createTextNode(String(e)))}else{if(s instanceof Node)return o(t),void t.appendChild(s);1===t.childNodes.length&&t.firstChild.nodeType===Node.TEXT_NODE?t.firstChild.textContent=String(s):(o(t),t.appendChild(document.createTextNode(String(s))))}else o(t)}function o(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function n(t,r){const{element:s,name:i,prefix:o}=t;switch(o){case"@":{const o=t.committedValue,n=null==r||r===e,a=n&&null!=o||r?.capture!==o?.capture||r?.once!==o?.once||r?.passive!==o?.passive,l=!n&&(null==o||a);if(a&&s.removeEventListener(i,t._handler||o,o),l)if("function"==typeof r){const e=t._host||(t._host={handleEvent(e){const r=t.committedValue;if("function"==typeof r){const t=s.getRootNode().host||s;r.call(t,e)}}});t._handler=e,s.addEventListener(i,e)}else if("object"==typeof r&&r?.handleEvent){const e={handleEvent:e=>r.handleEvent.call(r,e)};t._handler=e,s.addEventListener(i,e,{capture:r.capture,once:r.once,passive:r.passive})}t.committedValue=r;break}case".":s[i]=r===e?void 0:r;break;case"?":s.toggleAttribute(i,!!r);break;case"ref":"function"==typeof r&&r(s);break;case"class":if("string"==typeof r)s.className=r;else if("object"==typeof r&&null!=r){const e=s.className||"",t=e?e.split(/\s+/):[];for(const[e,s]of Object.entries(r))if(s)t.includes(e)||t.push(e);else{const r=t.indexOf(e);-1!==r&&t.splice(r,1)}s.className=t.filter(Boolean).join(" ")}break;default:null==r||!1===r?s.removeAttribute(i):s.setAttribute(i,!0===r?"":String(r))}}function a(e,t,o){if(!r(e))return void(t.textContent=e??"");const{strings:a,values:l}=e;if(t._luxActiveParts&&t._luxStrings===a){for(const e of t._luxActiveParts)e.index<l.length&&("child"===e.type?i(e.span,l[e.index]):n(e,l[e.index]));return}const c=document.createElement("template"),p=function(e){const t=[];let r="";for(let i=0;i<e.length;i++)if(r+=e[i],i<e.length-1){const e=r.match(s);if(e){const s=e[1],o=!!e[2],n=!!e[3];let a="",l="";s?(a=s[0],l=s.slice(1)):o?(a="ref",l="ref"):n&&(a="class",l="class");const c=`lux-attr-${i}`;r=r.slice(0,-e[0].length)+`${c}="${l}" `,t.push({type:"attr",name:l,prefix:a,marker:c,index:i})}else{const e=`lux-${i}`;r+=`\x3c!--${e}--\x3e`,t.push({type:"child",marker:e,index:i})}}return{html:r,parts:t}}(a);c.innerHTML=p.html;const d=c.content.cloneNode(!0),h=[];for(const e of p.parts)if("child"===e.type){const t=document.createTreeWalker(d,NodeFilter.SHOW_COMMENT);let r;for(;r=t.nextNode();)if(r.data===e.marker){const t=document.createElement("span");t.style.display="contents",r.parentNode.replaceChild(t,r),i(t,l[e.index]),h.push({type:"child",span:t,index:e.index});break}}else{const t=d.querySelector(`[${e.marker}]`);if(t){t.removeAttribute(e.marker);const r={type:"attr",element:t,name:e.name,prefix:e.prefix,index:e.index,committedValue:void 0};n(r,l[e.index]),h.push(r)}}t.textContent="",t.appendChild(d),t._luxActiveParts=h,t._luxStrings=a}const l=new Set;let c=!1;function p(e){var t;l.add(e),c||(c=!0,t=()=>{c=!1;const e=[...l];l.clear();for(const t of e)t._$performUpdate()},Promise.resolve().then(t))}const d={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?null:JSON.stringify(e);default:return e}},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return Number(e);case Object:case Array:try{return JSON.parse(e)}catch{return null}default:return e}}};class h extends HTMLElement{static properties={};static styles=void 0;static finalized=!1;static elementProperties=new Map;static __prepare(){if(this.hasOwnProperty("elementProperties"))return;const e=Object.getPrototypeOf(this);e.finalize&&e.finalize(),this.elementProperties=new Map(e.elementProperties)}static get observedAttributes(){return this.finalize(),this.__attributeToPropertyMap?[...this.__attributeToPropertyMap.keys()]:[]}static finalize(){if(!this.hasOwnProperty("finalized")){if(this.finalized=!0,this.__prepare(),this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const r of t)this.createProperty(r,e[r])}this.__attributeToPropertyMap=new Map;for(const[e,t]of this.elementProperties){const r=this.__attributeNameForProperty(e,t);void 0!==r&&this.__attributeToPropertyMap.set(r,e)}this.elementStyles=this.styles}}static __attributeNameForProperty(e,t){const r=t.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof e?e.replace(/([A-Z])/g,"-$1").toLowerCase():void 0}static createProperty(e,t={}){if(this.__prepare(),!this.elementProperties.has(e)&&(t.state&&(t={...t,attribute:!1}),this.elementProperties.set(e,t),!t.noAccessor)){const r=Symbol(),s=this.getPropertyDescriptor(e,r,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,r){const{type:s,reflect:i,converter:o}=r;return{get(){return this[t]},set(s){const i=this[t];this[t]=s,this.requestUpdate(e,i,r)},configurable:!0,enumerable:!0}}static _initializers=[];static addInitializer(e){this._initializers=[...this._initializers||[],e]}static shadowRootOptions={mode:"open"};constructor(){super(),this.__updatePending=!1,this.__hasUpdated=!1,this.__controllers=new Set,this.__reflectingProperty=null,this.constructor.hasOwnProperty("finalized")||this.constructor.finalize(),this.__saveInstanceProperties(),this.requestUpdate();for(const e of this.constructor._initializers||[])e(this)}__saveInstanceProperties(){const e=this.constructor.elementProperties;if(e)for(const[t,r]of e)if(!r.noAccessor&&this.hasOwnProperty(t)){const e=this[t];delete this[t],this.__instancePropertyValues=this.__instancePropertyValues||new Map,this.__instancePropertyValues.set(t,e)}}connectedCallback(){this.__controllers.forEach(e=>e.hostConnected?.()),this.constructor.hasOwnProperty("finalized")||this.constructor.finalize();const e=this.constructor.__attributeToPropertyMap;if(e)for(const[t,r]of e){const e=this.getAttribute(t);if(null!==e){const t=this.constructor.elementProperties.get(r);if(t){const s=t.converter?.fromAttribute??d.fromAttribute;this[r]=s(e,t.type)}}}if(this.__instancePropertyValues){for(const[e,t]of this.__instancePropertyValues)this[e]=t;this.__instancePropertyValues=void 0}this.renderRoot,this.__hasUpdated||this.requestUpdate()}disconnectedCallback(){this.__controllers.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,r){const s=this.constructor.__attributeToPropertyMap?.get(e);if(void 0!==s&&this.__reflectingProperty!==s){const e=this.constructor.elementProperties.get(s);if(e){const t="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:d;this.__reflectingProperty=s;const i=t.fromAttribute(r,e.type);this[s]=i,this.__reflectingProperty=null}}}get renderRoot(){return this._renderRoot||(this._renderRoot=this.createRenderRoot(),this.__adoptStyles()),this._renderRoot}createRenderRoot(){return this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions)}__adoptStyles(){const e=this.constructor.elementStyles;if(!e)return;const t=Array.isArray(e)?e:[e],s=[];for(const e of t)"string"==typeof e?s.push(e):r(e)&&s.push(e.strings.join(""));if(0!==s.length)if(void 0!==this._renderRoot.adoptedStyleSheets){const e=new CSSStyleSheet;e.replaceSync(s.join("\n")),this._renderRoot.adoptedStyleSheets=[...this._renderRoot.adoptedStyleSheets,e]}else{const e=document.createElement("style");e.textContent=s.join("\n"),this._renderRoot.appendChild(e)}}enableUpdating(e){}get updateComplete(){return this.__updateCompletePromise??Promise.resolve()}get hasUpdated(){return this.__hasUpdated}get isUpdatePending(){return this.__updatePending}requestUpdate(e,t,r){if(void 0!==e){if(!(r?.hasChanged??((e,t)=>!Object.is(e,t)))(this[e],t))return}this.__updatePending||(this.__updatePending=!0,p(this))}async performUpdate(){if(this.isUpdatePending){this.__updatePending=!1,this.willUpdate(new Map),this.__controllers.forEach(e=>e.hostUpdate?.()),this.update(new Map),this.__hasUpdated=!0;for(const[e,t]of this.constructor.elementProperties)if(t.reflect){const r=this[e],s=t.converter?.toAttribute??d.toAttribute,i=this.constructor.__attributeNameForProperty(e,t);if(void 0!==i){this.__reflectingProperty=e;const o=s(r,t.type);null==o?this.removeAttribute(i):this.setAttribute(i,String(o)),this.__reflectingProperty=null}}this.__controllers.forEach(e=>e.hostUpdated?.()),this.firstUpdated(new Map),this.updated(new Map)}}_$performUpdate(){this.performUpdate()}shouldUpdate(e){return!0}willUpdate(e){}update(e){const t=this.render();t&&a(t,this.renderRoot)}render(){return t``}firstUpdated(e){}updated(e){}propertyChangedCallback(e,t,r){}addController(e){this.__controllers.add(e),this.isConnected&&e.hostConnected?.()}removeController(e){this.__controllers.delete(e)}emit(e,t,r={}){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0,...r}))}$(e){return this.renderRoot.querySelector(e)}$$(e){return this.renderRoot.querySelectorAll(e)}}const u=t`<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor">
2
+ <path d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6z" />
3
+ </svg>`,f=t`<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor">
4
+ <path
5
+ d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
6
+ />
7
+ </svg>`,m=(function(e,...t){return{_$luxType$:3,strings:e,values:t}})`
8
+ :host {
9
+ display: inline-block;
10
+ position: relative;
11
+ }
12
+ .trigger {
13
+ display: flex;
14
+ align-items: center;
15
+ gap: 6px;
16
+ width: 100%;
17
+ padding: 6px 12px;
18
+ border: 1px solid rgb(var(--lux-border, 51 65 85));
19
+ border-radius: var(--lux-radius, 6px);
20
+ background: rgb(var(--lux-card, 30 41 59));
21
+ color: rgb(var(--lux-text, 241 245 249));
22
+ font-size: 13px;
23
+ cursor: pointer;
24
+ user-select: none;
25
+ white-space: nowrap;
26
+ box-sizing: border-box;
27
+ }
28
+ .trigger:hover {
29
+ border-color: rgb(var(--lux-primary-500, 99 91 218));
30
+ background: rgb(var(--lux-hover, 255 255 255 / 5%));
31
+ }
32
+ .placeholder {
33
+ color: rgb(var(--lux-text-muted, 100 116 139));
34
+ }
35
+ .end-icons {
36
+ display: inline-flex;
37
+ align-items: center;
38
+ justify-content: center;
39
+ position: relative;
40
+ width: 18px;
41
+ height: 18px;
42
+ flex-shrink: 0;
43
+ margin-left: auto;
44
+ }
45
+ .arrow,
46
+ .clear {
47
+ display: inline-flex;
48
+ align-items: center;
49
+ justify-content: center;
50
+ position: absolute;
51
+ top: 0;
52
+ left: 0;
53
+ width: 18px;
54
+ height: 18px;
55
+ transition: opacity 150ms ease;
56
+ }
57
+ .arrow {
58
+ color: rgb(var(--lux-text-secondary, 148 163 184));
59
+ transition:
60
+ transform 150ms ease,
61
+ opacity 150ms ease;
62
+ }
63
+ :host([open]) .arrow {
64
+ transform: rotate(180deg);
65
+ }
66
+ .clear {
67
+ display: none;
68
+ cursor: pointer;
69
+ color: rgb(var(--lux-text-secondary, 148 163 184));
70
+ z-index: 1;
71
+ }
72
+ .clear:hover {
73
+ color: rgb(var(--lux-text, 241 245 249));
74
+ }
75
+ :host([clearable][has-value]:hover) .clear {
76
+ display: inline-flex;
77
+ }
78
+ :host([clearable][has-value]:hover) .arrow {
79
+ opacity: 0;
80
+ pointer-events: none;
81
+ }
82
+ .menu {
83
+ position: absolute;
84
+ top: calc(100% + 4px);
85
+ left: 0;
86
+ min-width: 100%;
87
+ max-height: 200px;
88
+ overflow-y: auto;
89
+ background: rgb(var(--lux-card, 30 41 59));
90
+ border: 1px solid rgb(var(--lux-border, 51 65 85));
91
+ border-radius: var(--lux-radius, 6px);
92
+ box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
93
+ z-index: 1000;
94
+ padding: 4px 0;
95
+ display: none;
96
+ }
97
+ :host([open]) .menu {
98
+ display: block;
99
+ }
100
+ .item {
101
+ display: block;
102
+ padding: 7px 12px;
103
+ font-size: 13px;
104
+ color: rgb(var(--lux-text, 241 245 249));
105
+ cursor: pointer;
106
+ white-space: nowrap;
107
+ user-select: none;
108
+ }
109
+ .item:hover {
110
+ background: rgb(var(--lux-hover, 255 255 255 / 5%));
111
+ }
112
+ .item.active {
113
+ color: rgb(var(--lux-primary-400, 129 113 234));
114
+ }
115
+
116
+ /* Size: sm */
117
+ :host([size='sm']) .trigger {
118
+ padding: 4px 8px;
119
+ font-size: 12px;
120
+ gap: 4px;
121
+ }
122
+ :host([size='sm']) .item {
123
+ padding: 5px 10px;
124
+ font-size: 12px;
125
+ }
126
+ :host([size='sm']) .end-icons {
127
+ width: 14px;
128
+ height: 14px;
129
+ }
130
+
131
+ /* Size: lg */
132
+ :host([size='lg']) .trigger {
133
+ padding: 10px 16px;
134
+ font-size: 15px;
135
+ gap: 8px;
136
+ }
137
+ :host([size='lg']) .item {
138
+ padding: 10px 16px;
139
+ font-size: 15px;
140
+ }
141
+ :host([size='lg']) .end-icons {
142
+ width: 22px;
143
+ height: 22px;
144
+ }
145
+ `;class _ extends h{static styles=m;static properties={options:{type:Array,attribute:!1},value:{type:String,reflect:!0},placeholder:{type:String,reflect:!0},open:{type:Boolean,reflect:!0},clearable:{type:Boolean,reflect:!0},size:{type:String,reflect:!0}};constructor(){super(),this.placeholder="",this.value="",this.clearable=!1,this._onDocClickBound=!1}connectedCallback(){super.connectedCallback(),this._bindDocClick()}_bindDocClick(){this._onDocClickBound||(this._onDocClick=this._onDocClick.bind(this),document.addEventListener("click",this._onDocClick,!0),this._onDocClickBound=!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._onDocClick,!0),this._onDocClickBound=!1}updated(){this.value?this.setAttribute("has-value",""):this.removeAttribute("has-value")}_onDocClick(e){this.contains(e.target)||(this.open=!1)}_toggle(){this.open=!this.open}_clear(){this.value="",this.emit("clear")}_select(e){this.value=String(e.value),this.open=!1,this.emit("change",{value:e.value,label:e.label??e.value})}render(){const e=Array.isArray(this.options)?this.options:[],r=e.find(e=>String(e.value)===String(this.value)),s=r?r.label??r.value:"",i=this.placeholder;return t`
146
+ <div class="trigger" @click=${()=>this._toggle()}>
147
+ <span class=${{placeholder:!s&&!!i}}>${s||i}</span>
148
+ <span class="end-icons">
149
+ <span
150
+ class=${{clear:!0}}
151
+ @click=${e=>{e.stopPropagation(),this._clear()}}
152
+ >${f}</span
153
+ >
154
+ <span class="arrow">${u}</span>
155
+ </span>
156
+ </div>
157
+ <div class="menu">
158
+ ${o=e,n=e=>e.value,a=e=>t`
159
+ <div class="item" @click=${()=>this._select(e)}>${e.label??e.value}</div>
160
+ `,{_type:"repeat",items:o,keyFn:n,renderFn:a}}
161
+ </div>
162
+ `;var o,n,a}}!function(e,t){if(!e.includes("-"))throw new Error(`Component name must contain a hyphen: ${e}`);customElements.get(e)||customElements.define(e,t)}("lux-dropdown",_);export{_ as default};