@crowdstrike/glide-core 0.5.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.
Files changed (272) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +41 -0
  3. package/dist/accordion.d.ts +23 -0
  4. package/dist/accordion.js +1 -0
  5. package/dist/accordion.stories.d.ts +9 -0
  6. package/dist/accordion.styles.d.ts +2 -0
  7. package/dist/accordion.styles.js +98 -0
  8. package/dist/accordion.test.basics.d.ts +1 -0
  9. package/dist/accordion.test.events.d.ts +1 -0
  10. package/dist/button-group.button.d.ts +33 -0
  11. package/dist/button-group.button.js +1 -0
  12. package/dist/button-group.button.styles.d.ts +2 -0
  13. package/dist/button-group.button.styles.js +99 -0
  14. package/dist/button-group.button.test.basics.d.ts +1 -0
  15. package/dist/button-group.button.test.events.d.ts +1 -0
  16. package/dist/button-group.d.ts +26 -0
  17. package/dist/button-group.js +1 -0
  18. package/dist/button-group.stories.d.ts +16 -0
  19. package/dist/button-group.styles.d.ts +2 -0
  20. package/dist/button-group.styles.js +18 -0
  21. package/dist/button-group.test.basics.d.ts +1 -0
  22. package/dist/button-group.test.events.d.ts +1 -0
  23. package/dist/button.d.ts +29 -0
  24. package/dist/button.js +1 -0
  25. package/dist/button.stories.d.ts +17 -0
  26. package/dist/button.styles.d.ts +2 -0
  27. package/dist/button.styles.js +133 -0
  28. package/dist/button.test.basics.d.ts +1 -0
  29. package/dist/button.test.events.d.ts +1 -0
  30. package/dist/button.test.form.d.ts +1 -0
  31. package/dist/checkbox-group.d.ts +43 -0
  32. package/dist/checkbox-group.js +1 -0
  33. package/dist/checkbox-group.stories.d.ts +7 -0
  34. package/dist/checkbox-group.styles.d.ts +2 -0
  35. package/dist/checkbox-group.styles.js +20 -0
  36. package/dist/checkbox-group.test.basics.d.ts +1 -0
  37. package/dist/checkbox-group.test.events.d.ts +1 -0
  38. package/dist/checkbox-group.test.focus.d.ts +1 -0
  39. package/dist/checkbox-group.test.form.d.ts +1 -0
  40. package/dist/checkbox-group.test.validity.d.ts +1 -0
  41. package/dist/checkbox.d.ts +50 -0
  42. package/dist/checkbox.js +1 -0
  43. package/dist/checkbox.stories.d.ts +9 -0
  44. package/dist/checkbox.styles.d.ts +2 -0
  45. package/dist/checkbox.styles.js +116 -0
  46. package/dist/checkbox.test.basics.d.ts +1 -0
  47. package/dist/checkbox.test.events.d.ts +1 -0
  48. package/dist/checkbox.test.focus.d.ts +1 -0
  49. package/dist/checkbox.test.form.d.ts +1 -0
  50. package/dist/checkbox.test.states.d.ts +1 -0
  51. package/dist/checkbox.test.validity.d.ts +1 -0
  52. package/dist/drawer.d.ts +30 -0
  53. package/dist/drawer.js +15 -0
  54. package/dist/drawer.stories.d.ts +7 -0
  55. package/dist/drawer.styles.d.ts +2 -0
  56. package/dist/drawer.styles.js +34 -0
  57. package/dist/drawer.test.accessibility.d.ts +1 -0
  58. package/dist/drawer.test.basics.d.ts +1 -0
  59. package/dist/drawer.test.closing.d.ts +1 -0
  60. package/dist/drawer.test.events.d.ts +1 -0
  61. package/dist/drawer.test.methods.d.ts +1 -0
  62. package/dist/dropdown.d.ts +66 -0
  63. package/dist/dropdown.js +1 -0
  64. package/dist/dropdown.option.d.ts +33 -0
  65. package/dist/dropdown.option.js +1 -0
  66. package/dist/dropdown.option.styles.d.ts +2 -0
  67. package/dist/dropdown.option.styles.js +64 -0
  68. package/dist/dropdown.option.test.basics.d.ts +1 -0
  69. package/dist/dropdown.option.test.basics.multiple.d.ts +1 -0
  70. package/dist/dropdown.option.test.basics.single.d.ts +1 -0
  71. package/dist/dropdown.option.test.events.d.ts +1 -0
  72. package/dist/dropdown.option.test.focus.multiple.d.ts +1 -0
  73. package/dist/dropdown.option.test.focus.single.d.ts +1 -0
  74. package/dist/dropdown.option.test.interactions.multiple.d.ts +1 -0
  75. package/dist/dropdown.option.test.interactions.single.d.ts +1 -0
  76. package/dist/dropdown.stories.d.ts +15 -0
  77. package/dist/dropdown.styles.d.ts +2 -0
  78. package/dist/dropdown.styles.js +162 -0
  79. package/dist/dropdown.test.basics.d.ts +1 -0
  80. package/dist/dropdown.test.basics.filterable.d.ts +1 -0
  81. package/dist/dropdown.test.basics.multiple.d.ts +1 -0
  82. package/dist/dropdown.test.basics.single.d.ts +1 -0
  83. package/dist/dropdown.test.events.d.ts +1 -0
  84. package/dist/dropdown.test.focus.filterable.d.ts +1 -0
  85. package/dist/dropdown.test.focus.multiple.d.ts +1 -0
  86. package/dist/dropdown.test.focus.single.d.ts +1 -0
  87. package/dist/dropdown.test.form.d.ts +1 -0
  88. package/dist/dropdown.test.form.multiple.d.ts +1 -0
  89. package/dist/dropdown.test.form.single.d.ts +1 -0
  90. package/dist/dropdown.test.interactions.d.ts +1 -0
  91. package/dist/dropdown.test.interactions.filterable.d.ts +1 -0
  92. package/dist/dropdown.test.interactions.multiple.d.ts +1 -0
  93. package/dist/dropdown.test.interactions.single.d.ts +1 -0
  94. package/dist/dropdown.test.validity.d.ts +1 -0
  95. package/dist/icon-button.d.ts +22 -0
  96. package/dist/icon-button.js +1 -0
  97. package/dist/icon-button.stories.d.ts +8 -0
  98. package/dist/icon-button.styles.d.ts +2 -0
  99. package/dist/icon-button.styles.js +112 -0
  100. package/dist/icon-button.test.basics.d.ts +1 -0
  101. package/dist/icons/checked.d.ts +2 -0
  102. package/dist/icons/checked.js +1 -0
  103. package/dist/icons/magnifying-glass.d.ts +2 -0
  104. package/dist/icons/magnifying-glass.js +1 -0
  105. package/dist/input.d.ts +67 -0
  106. package/dist/input.js +1 -0
  107. package/dist/input.stories.d.ts +19 -0
  108. package/dist/input.styles.d.ts +2 -0
  109. package/dist/input.styles.js +109 -0
  110. package/dist/input.test.basics.d.ts +1 -0
  111. package/dist/input.test.events.d.ts +1 -0
  112. package/dist/input.test.focus.d.ts +1 -0
  113. package/dist/input.test.form.d.ts +1 -0
  114. package/dist/input.test.validity.d.ts +1 -0
  115. package/dist/label.d.ts +33 -0
  116. package/dist/label.js +1 -0
  117. package/dist/label.styles.d.ts +2 -0
  118. package/dist/label.styles.js +154 -0
  119. package/dist/label.test.basics.d.ts +1 -0
  120. package/dist/library/expect-argument-error.d.ts +1 -0
  121. package/dist/library/expect-argument-error.js +1 -0
  122. package/dist/library/ow.d.ts +16 -0
  123. package/dist/library/ow.js +1 -0
  124. package/dist/library/ow.test.d.ts +4 -0
  125. package/dist/menu.button.d.ts +21 -0
  126. package/dist/menu.button.js +1 -0
  127. package/dist/menu.button.styles.d.ts +2 -0
  128. package/dist/menu.button.styles.js +20 -0
  129. package/dist/menu.button.test.basics.d.ts +1 -0
  130. package/dist/menu.d.ts +27 -0
  131. package/dist/menu.js +1 -0
  132. package/dist/menu.link.d.ts +22 -0
  133. package/dist/menu.link.js +1 -0
  134. package/dist/menu.link.styles.d.ts +2 -0
  135. package/dist/menu.link.styles.js +22 -0
  136. package/dist/menu.link.test.basics.d.ts +1 -0
  137. package/dist/menu.stories.d.ts +9 -0
  138. package/dist/menu.styles.d.ts +2 -0
  139. package/dist/menu.styles.js +61 -0
  140. package/dist/menu.test.basics.d.ts +1 -0
  141. package/dist/menu.test.focus.d.ts +2 -0
  142. package/dist/menu.test.interactions.d.ts +2 -0
  143. package/dist/modal.d.ts +51 -0
  144. package/dist/modal.icon-button.d.ts +26 -0
  145. package/dist/modal.icon-button.js +1 -0
  146. package/dist/modal.icon-button.styles.d.ts +2 -0
  147. package/dist/modal.icon-button.styles.js +8 -0
  148. package/dist/modal.icon-button.test.basics.d.ts +1 -0
  149. package/dist/modal.js +15 -0
  150. package/dist/modal.stories.d.ts +14 -0
  151. package/dist/modal.styles.d.ts +2 -0
  152. package/dist/modal.styles.js +169 -0
  153. package/dist/modal.tertiary-icon.d.ts +21 -0
  154. package/dist/modal.tertiary-icon.js +1 -0
  155. package/dist/modal.tertiary-icon.test.basics.d.ts +1 -0
  156. package/dist/modal.test.accessibility.d.ts +1 -0
  157. package/dist/modal.test.basics.d.ts +3 -0
  158. package/dist/modal.test.close.d.ts +1 -0
  159. package/dist/modal.test.events.d.ts +1 -0
  160. package/dist/modal.test.lock-scroll.d.ts +1 -0
  161. package/dist/modal.test.methods.d.ts +1 -0
  162. package/dist/modal.test.scrollbars.d.ts +1 -0
  163. package/dist/radio-group.d.ts +48 -0
  164. package/dist/radio-group.js +1 -0
  165. package/dist/radio-group.stories.d.ts +8 -0
  166. package/dist/radio-group.styles.d.ts +2 -0
  167. package/dist/radio-group.styles.js +40 -0
  168. package/dist/radio-group.test.basics.d.ts +2 -0
  169. package/dist/radio-group.test.events.d.ts +2 -0
  170. package/dist/radio-group.test.focus.d.ts +2 -0
  171. package/dist/radio-group.test.form.d.ts +1 -0
  172. package/dist/radio-group.test.validity.d.ts +1 -0
  173. package/dist/radio.d.ts +23 -0
  174. package/dist/radio.js +1 -0
  175. package/dist/radio.styles.d.ts +2 -0
  176. package/dist/radio.styles.js +92 -0
  177. package/dist/status-indicator.d.ts +30 -0
  178. package/dist/status-indicator.js +1 -0
  179. package/dist/status-indicator.stories.d.ts +17 -0
  180. package/dist/status-indicator.styles.d.ts +2 -0
  181. package/dist/status-indicator.styles.js +58 -0
  182. package/dist/status-indicator.test.basics.d.ts +1 -0
  183. package/dist/styles/focus-outline.d.ts +2 -0
  184. package/dist/styles/focus-outline.js +4 -0
  185. package/dist/styles/fonts.css +1 -0
  186. package/dist/styles/variables.css +1 -0
  187. package/dist/styles/visually-hidden.d.ts +2 -0
  188. package/dist/styles/visually-hidden.js +11 -0
  189. package/dist/tab.d.ts +32 -0
  190. package/dist/tab.group.d.ts +35 -0
  191. package/dist/tab.group.js +1 -0
  192. package/dist/tab.group.styles.d.ts +2 -0
  193. package/dist/tab.group.styles.js +27 -0
  194. package/dist/tab.group.test.basics.d.ts +3 -0
  195. package/dist/tab.js +1 -0
  196. package/dist/tab.panel.d.ts +26 -0
  197. package/dist/tab.panel.js +1 -0
  198. package/dist/tab.panel.styles.d.ts +2 -0
  199. package/dist/tab.panel.styles.js +9 -0
  200. package/dist/tab.styles.d.ts +2 -0
  201. package/dist/tab.styles.js +83 -0
  202. package/dist/tab.test.basics.d.ts +1 -0
  203. package/dist/tabs.stories.d.ts +9 -0
  204. package/dist/tag.d.ts +25 -0
  205. package/dist/tag.js +1 -0
  206. package/dist/tag.stories.d.ts +9 -0
  207. package/dist/tag.styles.d.ts +2 -0
  208. package/dist/tag.styles.js +133 -0
  209. package/dist/tag.test.basics.d.ts +1 -0
  210. package/dist/tag.test.events.d.ts +1 -0
  211. package/dist/tag.test.focus.d.ts +1 -0
  212. package/dist/textarea.d.ts +49 -0
  213. package/dist/textarea.js +2 -0
  214. package/dist/textarea.stories.d.ts +13 -0
  215. package/dist/textarea.styles.d.ts +2 -0
  216. package/dist/textarea.styles.js +69 -0
  217. package/dist/textarea.test.basics.d.ts +1 -0
  218. package/dist/textarea.test.events.d.ts +1 -0
  219. package/dist/textarea.test.form.d.ts +1 -0
  220. package/dist/textarea.test.validity.d.ts +1 -0
  221. package/dist/toasts.d.ts +29 -0
  222. package/dist/toasts.js +1 -0
  223. package/dist/toasts.stories.d.ts +7 -0
  224. package/dist/toasts.styles.d.ts +2 -0
  225. package/dist/toasts.styles.js +15 -0
  226. package/dist/toasts.test.basics.d.ts +1 -0
  227. package/dist/toasts.toast.d.ts +28 -0
  228. package/dist/toasts.toast.js +1 -0
  229. package/dist/toasts.toast.styles.d.ts +2 -0
  230. package/dist/toasts.toast.styles.js +60 -0
  231. package/dist/toasts.toast.test.basics.d.ts +1 -0
  232. package/dist/toggle.d.ts +31 -0
  233. package/dist/toggle.js +1 -0
  234. package/dist/toggle.stories.d.ts +7 -0
  235. package/dist/toggle.styles.d.ts +2 -0
  236. package/dist/toggle.styles.js +81 -0
  237. package/dist/toggle.test.basics.d.ts +1 -0
  238. package/dist/toggle.test.events.d.ts +1 -0
  239. package/dist/toggle.test.focus.d.ts +1 -0
  240. package/dist/toggle.test.states.d.ts +1 -0
  241. package/dist/tooltip.d.ts +21 -0
  242. package/dist/tooltip.js +1 -0
  243. package/dist/tooltip.stories.d.ts +7 -0
  244. package/dist/tooltip.styles.d.ts +2 -0
  245. package/dist/tooltip.styles.js +66 -0
  246. package/dist/tooltip.test.basics.d.ts +1 -0
  247. package/dist/tooltip.test.interactions.d.ts +1 -0
  248. package/dist/tree.d.ts +26 -0
  249. package/dist/tree.item.d.ts +43 -0
  250. package/dist/tree.item.icon-button.d.ts +20 -0
  251. package/dist/tree.item.icon-button.js +1 -0
  252. package/dist/tree.item.icon-button.styles.d.ts +2 -0
  253. package/dist/tree.item.icon-button.styles.js +9 -0
  254. package/dist/tree.item.icon-button.test.basics.d.ts +1 -0
  255. package/dist/tree.item.js +1 -0
  256. package/dist/tree.item.menu.d.ts +21 -0
  257. package/dist/tree.item.menu.js +1 -0
  258. package/dist/tree.item.menu.styles.d.ts +2 -0
  259. package/dist/tree.item.menu.styles.js +17 -0
  260. package/dist/tree.item.menu.test.basics.d.ts +1 -0
  261. package/dist/tree.item.styles.d.ts +2 -0
  262. package/dist/tree.item.styles.js +130 -0
  263. package/dist/tree.item.test.basics.d.ts +1 -0
  264. package/dist/tree.js +1 -0
  265. package/dist/tree.stories.d.ts +17 -0
  266. package/dist/tree.styles.d.ts +2 -0
  267. package/dist/tree.styles.js +7 -0
  268. package/dist/tree.test.aria.d.ts +1 -0
  269. package/dist/tree.test.basics.d.ts +3 -0
  270. package/dist/tree.test.events.d.ts +2 -0
  271. package/dist/tree.test.focus.d.ts +1 -0
  272. package/package.json +129 -0
@@ -0,0 +1 @@
1
+ "use strict";import{svg as o}from"lit/static-html.js";export default o`<svg class="search-icon" fill="none" width="16" height="16" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"/></svg>`;
@@ -0,0 +1,67 @@
1
+ import './icon-button.js';
2
+ import './label.js';
3
+ import { LitElement } from 'lit';
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ 'glide-core-input': GlideCoreInput;
7
+ }
8
+ }
9
+ export declare const SUPPORTED_TYPES: readonly ["email", "number", "password", "search", "tel", "text", "url"];
10
+ type SupportedTypes = (typeof SUPPORTED_TYPES)[number];
11
+ /**
12
+ * @description An input with a label and optional description and tooltip. Participates in forms and validation via `FormData` and various methods.
13
+ *
14
+ * @event change - (same as native input's `change` event)
15
+ * @event input - (same as native input's `input` event)
16
+
17
+ * @slot tooltip - Content for the tooltip.
18
+ * @slot description - Additional information or context.
19
+ * @slot prefix - An optional icon slot to display before the input.
20
+ * @slot suffix - An optional icon slot to display after the input.
21
+ */
22
+ export default class GlideCoreInput extends LitElement {
23
+ #private;
24
+ static formAssociated: boolean;
25
+ static shadowRootOptions: ShadowRootInit;
26
+ static styles: import("lit").CSSResult;
27
+ type: SupportedTypes;
28
+ name?: string;
29
+ value: string;
30
+ label?: string;
31
+ hideLabel: boolean;
32
+ orientation: 'horizontal' | 'vertical';
33
+ placeholder?: string;
34
+ clearable: boolean;
35
+ spellcheck: boolean;
36
+ autocapitalize: 'on' | 'off' | 'none' | 'sentences' | 'words' | 'characters';
37
+ /** For 'password' type, whether to show a button to toggle the password's visibility */
38
+ passwordToggle: boolean;
39
+ required: boolean;
40
+ readonly: boolean;
41
+ disabled: boolean;
42
+ maxlength?: number;
43
+ descriptionNodes: NodeListOf<HTMLElement>;
44
+ prefixIconNodes: NodeListOf<HTMLElement>;
45
+ suffixIconNodes: NodeListOf<HTMLElement>;
46
+ get form(): HTMLFormElement | null;
47
+ get validity(): ValidityState;
48
+ get willValidate(): boolean;
49
+ blur(): void;
50
+ checkValidity(): boolean;
51
+ disconnectedCallback(): void;
52
+ firstUpdated(): void;
53
+ formAssociatedCallback(): void;
54
+ formResetCallback(): void;
55
+ get isTypeSearch(): boolean;
56
+ get hasClearIcon(): boolean;
57
+ get isClearIconVisible(): boolean;
58
+ render(): import("lit").TemplateResult<1>;
59
+ reportValidity(): boolean;
60
+ get valueCharacterCount(): number;
61
+ constructor();
62
+ private hasFocus;
63
+ private isCheckingValidity?;
64
+ private isReportValidityOrSubmit;
65
+ private passwordVisible;
66
+ }
67
+ export {};
package/dist/input.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var Y=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var i=(r,a,t,u)=>{for(var p=u>1?void 0:u?Z(a,t):a,S=r.length-1,B;S>=0;S--)(B=r[S])&&(p=(u?B(a,t,p):B(p))||p);return u&&p&&Y(a,t,p),p};var R=(r,a,t)=>{if(!a.has(r))throw TypeError("Cannot "+t)};var s=(r,a,t)=>(R(r,a,"read from private field"),t?t.call(r):a.get(r)),l=(r,a,t)=>{if(a.has(r))throw TypeError("Cannot add the same private member more than once");a instanceof WeakSet?a.add(r):a.set(r,t)},P=(r,a,t,u)=>(R(r,a,"write to private field"),u?u.call(r,t):a.set(r,t),t);var n=(r,a,t)=>(R(r,a,"access private method"),t);var g,h,y,b,$,w,F,d,c,x,H,E,j,V,z,L,D,T,C,M,U,v,f;import"./icon-button.js";import"./label.js";import{LitElement as q,html as m,nothing as _}from"lit";import{classMap as N}from"lit/directives/class-map.js";import{createRef as J,ref as K}from"lit/directives/ref.js";import{customElement as Q,property as o,queryAssignedNodes as O,state as k}from"lit/decorators.js";import{ifDefined as A}from"lit/directives/if-defined.js";import W from"./icons/magnifying-glass.js";import X from"./input.styles.js";export const SUPPORTED_TYPES=["email","number","password","search","tel","text","url"];let e=class extends q{constructor(){super();l(this,b);l(this,w);l(this,d);l(this,x);l(this,E);l(this,V);l(this,L);l(this,T);l(this,M);l(this,v);this.type="text";this.value="";this.hideLabel=!1;this.orientation="horizontal";this.clearable=!1;this.spellcheck=!1;this.autocapitalize="on";this.passwordToggle=!1;this.required=!1;this.readonly=!1;this.disabled=!1;this.hasFocus=!1;this.isReportValidityOrSubmit=!1;this.passwordVisible=!1;l(this,g,J());l(this,h,void 0);l(this,y,({formData:t})=>{this.name&&this.value&&!this.disabled&&t.append(this.name,this.value)});P(this,h,this.attachInternals()),this.addEventListener("invalid",t=>{t?.preventDefault(),this.isCheckingValidity||(this.isReportValidityOrSubmit=!0,this.focus())})}get form(){return s(this,h).form}get validity(){return s(this,h).validity}get willValidate(){return s(this,h).willValidate}blur(){s(this,d,c)?.blur()}checkValidity(){return this.isCheckingValidity=!0,s(this,h).checkValidity()}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",s(this,y))}firstUpdated(){n(this,v,f).call(this)}formAssociatedCallback(){this.form?.addEventListener("formdata",s(this,y))}formResetCallback(){this.value=this.getAttribute("value")??""}get isTypeSearch(){return this.type==="search"}get hasClearIcon(){return this.clearable&&!this.disabled&&!this.readonly}get isClearIconVisible(){return this.hasClearIcon&&this.value.length>0}render(){return m`<glide-core-label orientation="${this.orientation}" ?disabled="${this.disabled}" ?error="${s(this,w,F)||s(this,b,$)}" ?hide="${this.hideLabel}" ?required="${this.required}"><slot name="tooltip" slot="tooltip"></slot><label for="input">${this.label}</label><div class="${N({"input-box":!0,focused:this.hasFocus,empty:this.value==="",disabled:this.disabled,readonly:this.readonly&&!this.disabled,error:s(this,w,F)||s(this,b,$)})}" slot="control"><slot name="prefix"></slot><input aria-describedby="meta" id="input" type="${this.type==="password"&&this.passwordVisible?"text":this.type}" .value="${this.value}" placeholder="${A(this.placeholder)}" autocapitalize="${A(this.autocapitalize)}" spellcheck="${this.spellcheck}" ?required="${this.required}" ?readonly="${this.readonly}" ?disabled="${this.disabled}" @focus="${n(this,L,D)}" @blur="${n(this,x,H)}" @change="${n(this,E,j)}" @input="${n(this,T,C)}" ${K(s(this,g))}> ${this.hasClearIcon?m`<glide-core-icon-button variant="tertiary" class="${N({"clear-icon-button":!0,"clear-icon-button--visible":this.isClearIconVisible})}" aria-label="Clear entry" @click="${n(this,V,z)}" tabindex="-1"><slot name="clear-icon"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path d="M6 6L18 18" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M18 6L6 18" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></slot></glide-core-icon-button>`:""} ${this.type==="password"&&this.passwordToggle&&!this.disabled?m`<glide-core-icon-button variant="tertiary" class="password-toggle" aria-label="${this.passwordVisible?"Hide password":"Show password"}" aria-controls="input" aria-expanded="${this.passwordVisible?"true":"false"}" @click="${n(this,M,U)}" tabindex="-1">${this.passwordVisible?m`<svg width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3.98 8.223A10.477 10.477 0 0 0 1.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.451 10.451 0 0 1 12 4.5c4.756 0 8.773 3.162 10.065 7.498a10.522 10.522 0 0 1-4.293 5.774M6.228 6.228 3 3m3.228 3.228 3.65 3.65m7.894 7.894L21 21m-3.228-3.228-3.65-3.65m0 0a3 3 0 1 0-4.243-4.243m4.242 4.242L9.88 9.88"/></svg>`:m`<svg width="16" height="16" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M2.036 12.322a1.012 1.012 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178Z"/><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"/></svg>`}</glide-core-icon-button>`:""}<div class="suffix">${this.isTypeSearch?W:m`<slot name="suffix"></slot>`}</div></div><div class="meta" id="meta" slot="description"><slot class="description" name="description"></slot>${this.maxlength?m`<div class="${N({"character-count":!0,error:s(this,b,$)})}">${this.valueCharacterCount}/${this.maxlength}</div>`:_}</div></glide-core-label>`}reportValidity(){return s(this,h).reportValidity()}get valueCharacterCount(){return this.value.length}};g=new WeakMap,h=new WeakMap,y=new WeakMap,b=new WeakSet,$=function(){return!!(this.maxlength&&this.valueCharacterCount>this.maxlength)},w=new WeakSet,F=function(){return!this.disabled&&!this.validity?.valid&&this.isReportValidityOrSubmit},d=new WeakSet,c=function(){return s(this,g).value},x=new WeakSet,H=function(){this.hasFocus=!1},E=new WeakSet,j=function(t){this.value=s(this,d,c).value,n(this,v,f).call(this),this.dispatchEvent(new Event(t.type,t))},V=new WeakSet,z=function(t){this.value="",this.dispatchEvent(new Event("clear",{bubbles:!0})),s(this,d,c)?.focus(),n(this,v,f).call(this),t.stopPropagation()},L=new WeakSet,D=function(){this.hasFocus=!0},T=new WeakSet,C=function(){const t=s(this,d,c).value;this.value=t,n(this,v,f).call(this)},M=new WeakSet,U=function(){this.passwordVisible=!this.passwordVisible},v=new WeakSet,f=async function(){await this.updateComplete,s(this,h).setValidity(s(this,d,c)?.validity,s(this,d,c)?.validationMessage,s(this,d,c))},e.formAssociated=!0,e.shadowRootOptions={...q.shadowRootOptions,mode:"closed",delegatesFocus:!0},e.styles=X,i([o()],e.prototype,"type",2),i([o({reflect:!0})],e.prototype,"name",2),i([o()],e.prototype,"value",2),i([o()],e.prototype,"label",2),i([o({attribute:"hide-label",type:Boolean})],e.prototype,"hideLabel",2),i([o({reflect:!0})],e.prototype,"orientation",2),i([o()],e.prototype,"placeholder",2),i([o({type:Boolean})],e.prototype,"clearable",2),i([o({type:Boolean})],e.prototype,"spellcheck",2),i([o()],e.prototype,"autocapitalize",2),i([o({attribute:"password-toggle",type:Boolean})],e.prototype,"passwordToggle",2),i([o({reflect:!0,type:Boolean})],e.prototype,"required",2),i([o({type:Boolean})],e.prototype,"readonly",2),i([o({type:Boolean})],e.prototype,"disabled",2),i([o({type:Number,converter(t){return t&&Number.parseInt(t,10)}})],e.prototype,"maxlength",2),i([O({slot:"description"})],e.prototype,"descriptionNodes",2),i([O({slot:"prefix"})],e.prototype,"prefixIconNodes",2),i([O({slot:"suffix"})],e.prototype,"suffixIconNodes",2),i([k()],e.prototype,"hasFocus",2),i([k()],e.prototype,"isCheckingValidity",2),i([k()],e.prototype,"isReportValidityOrSubmit",2),i([k()],e.prototype,"passwordVisible",2),e=i([Q("glide-core-input")],e);export{e as default};
@@ -0,0 +1,19 @@
1
+ import './icons/storybook.js';
2
+ import './input.js';
3
+ import type { Meta, StoryObj } from '@storybook/web-components';
4
+ declare const meta: Meta;
5
+ export default meta;
6
+ export declare const Default: StoryObj;
7
+ export declare const Password: StoryObj;
8
+ export declare const WithError: StoryObj;
9
+ export declare const Description: StoryObj;
10
+ export declare const Readonly: StoryObj;
11
+ export declare const Disabled: StoryObj;
12
+ export declare const Placeholder: StoryObj;
13
+ export declare const Clearable: StoryObj;
14
+ export declare const SuffixIcon: StoryObj;
15
+ export declare const PrefixIcon: StoryObj;
16
+ export declare const SearchType: StoryObj;
17
+ export declare const MaxLength: StoryObj;
18
+ export declare const MaxLengthAndDescription: StoryObj;
19
+ export declare const Tooltip: StoryObj;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult;
2
+ export default _default;
@@ -0,0 +1,109 @@
1
+ "use strict";import{css as e}from"lit";export default e`
2
+ .meta {
3
+ column-gap: var(--glide-core-spacing-xs);
4
+ display: flex;
5
+ font-size: 0.75rem;
6
+ grid-column: 2;
7
+ justify-content: space-between;
8
+ }
9
+
10
+ .description {
11
+ display: block;
12
+ }
13
+
14
+ .character-count {
15
+ &.error {
16
+ font-weight: var(--glide-core-font-weight-bold);
17
+ }
18
+ }
19
+
20
+ .search-icon {
21
+ align-items: center;
22
+ display: flex;
23
+ }
24
+
25
+ .input-box {
26
+ align-items: center;
27
+ background-color: var(--glide-core-surface-base-lighter);
28
+ block-size: 2.125rem;
29
+ border: 1px solid var(--glide-core-border-base-light);
30
+ border-radius: var(--glide-core-spacing-xs);
31
+ box-sizing: border-box;
32
+ color: var(--glide-core-text-body-1);
33
+ display: flex;
34
+ gap: var(--glide-core-spacing-xxs);
35
+ line-height: var(--glide-core-body-xs-line-height);
36
+ padding-inline: var(--glide-core-spacing-sm);
37
+
38
+ &.error {
39
+ border-color: var(--glide-core-status-error);
40
+ }
41
+
42
+ &.focused:not(.error) {
43
+ border-color: var(--glide-core-border-focus);
44
+ }
45
+
46
+ /* We had to resort to a class selector because there may be a bug in Chrome and Safari
47
+ * with ":read-only"
48
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=1519649
49
+ */
50
+ &.readonly {
51
+ border: 1px solid transparent;
52
+ padding-inline-start: 0;
53
+ }
54
+
55
+ &.disabled {
56
+ background-color: var(--glide-core-surface-base-gray-light);
57
+ color: var(--glide-core-text-tertiary-disabled);
58
+ }
59
+
60
+ input {
61
+ border: none;
62
+ color: inherit;
63
+ cursor: inherit;
64
+ font-family: var(--glide-core-font-sans);
65
+ font-size: var(--glide-core-body-sm-font-size);
66
+ font-weight: var(--glide-core-body-xs-font-weight);
67
+ inline-size: 100%;
68
+ min-inline-size: 0;
69
+ outline: none;
70
+ padding: 0;
71
+
72
+ &::-webkit-search-decoration,
73
+ &::-webkit-search-cancel-button,
74
+ &::-webkit-search-results-button,
75
+ &::-webkit-search-results-decoration {
76
+ appearance: none;
77
+ }
78
+ }
79
+
80
+ .suffix {
81
+ align-items: center;
82
+ display: flex;
83
+ }
84
+ }
85
+
86
+ .clear-icon-button,
87
+ .password-toggle,
88
+ ::slotted([slot='suffix']) {
89
+ align-items: center;
90
+ background: none;
91
+ border: none;
92
+ color: var(--glide-core-icon-default);
93
+ display: inline-flex;
94
+ justify-content: center;
95
+ padding: 0;
96
+ }
97
+
98
+ .clear-icon-button,
99
+ .password-toggle,
100
+ .search-icon,
101
+ ::slotted([slot='prefix']),
102
+ ::slotted([slot='suffix']) {
103
+ display: flex;
104
+ }
105
+
106
+ .empty .clear-icon-button {
107
+ visibility: hidden;
108
+ }
109
+ `;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import './input.js';
@@ -0,0 +1 @@
1
+ import './input.js';
@@ -0,0 +1 @@
1
+ import './input.js';
@@ -0,0 +1 @@
1
+ import './input.js';
@@ -0,0 +1,33 @@
1
+ import './tooltip.js';
2
+ import { LitElement } from 'lit';
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ 'glide-core-label': GlideCoreLabel;
6
+ }
7
+ }
8
+ /**
9
+ * @private
10
+ *
11
+ * @description A label with a required control and optional description and tooltip.
12
+ *
13
+ * @slot - The label.
14
+ * @slot control - The control with which the label is associated.
15
+ * @slot summary - Additional information or context.
16
+ * @slot description - Additional information or context.
17
+ * @slot tooltip - Content for the tooltip.
18
+ */
19
+ export default class GlideCoreLabel extends LitElement {
20
+ #private;
21
+ static shadowRootOptions: ShadowRootInit;
22
+ static styles: import("lit").CSSResult[];
23
+ disabled: boolean;
24
+ error: boolean;
25
+ hide: boolean;
26
+ orientation: 'horizontal' | 'vertical';
27
+ required: boolean;
28
+ firstUpdated(): void;
29
+ render(): import("lit").TemplateResult<1>;
30
+ private hasDescriptionSlot;
31
+ private hasSummarySlot;
32
+ private hasTooltipSlot;
33
+ }
package/dist/label.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var O=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var r=(o,e,t,S)=>{for(var n=S>1?void 0:S?U(e,t):e,R=o.length-1,w;R>=0;R--)(w=o[R])&&(n=(S?w(e,t,n):w(n))||n);return S&&n&&O(e,t,n),n};var N=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var i=(o,e,t)=>(N(o,e,"read from private field"),t?t.call(o):e.get(o)),l=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)};var h=(o,e,t)=>(N(o,e,"access private method"),t);var c,d,v,f,g,y,k,E,D,T,z,b,q,M,I;import"./tooltip.js";import{LitElement as x,html as H}from"lit";import{classMap as a}from"lit/directives/class-map.js";import{createRef as m,ref as p}from"lit/directives/ref.js";import{customElement as j,property as u,state as B}from"lit/decorators.js";import{owSlot as $}from"./library/ow.js";import A from"./label.styles.js";import{svg as F}from"lit/static-html.js";const J=F`<svg aria-label="More information" width="16" height="16" viewBox="0 0 24 24" fill="none"><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2"/><path d="M12 16L12 12" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><circle cx="12" cy="8" r="1" fill="currentColor"/></svg>`;let s=class extends x{constructor(){super(...arguments);l(this,y);l(this,E);l(this,T);l(this,b);l(this,M);this.disabled=!1;this.error=!1;this.hide=!1;this.orientation="horizontal";this.required=!1;this.hasDescriptionSlot=!1;this.hasSummarySlot=!1;this.hasTooltipSlot=!1;l(this,c,m());l(this,d,m());l(this,v,m());l(this,f,m());l(this,g,m())}firstUpdated(){$(i(this,d).value),$(i(this,c).value)}render(){return H`<div class="${a({component:!0,horizontal:this.orientation==="horizontal",vertical:this.orientation==="vertical","hidden-label":this.hide})}"><div class="${a({"tooltip-and-label":!0,hidden:this.hide})}" part="tooltip-and-label-container"><div class="tooltip-and-label"><glide-core-tooltip class="${a({tooltip:!0,vertical:this.orientation==="vertical",visible:this.hasTooltipSlot})}" placement="${this.orientation==="vertical"?"right":"bottom"}"><span class="tooltip-target" slot="target" tabindex="0">${J}</span><slot class="${a({tooltip:!0,visible:this.hasTooltipSlot})}" name="tooltip" @slotchange="${h(this,M,I)}" ${p(i(this,g))}></slot></glide-core-tooltip><div class="${a({label:!0,disabled:this.disabled})}" data-test="label"><slot @slotchange="${h(this,E,D)}" ${p(i(this,d))}></slot>${this.required?H`<span aria-hidden="true" class="required-symbol">*</span>`:""}</div></div></div><div class="control-and-summary"><slot class="${a({control:!0,error:this.error,disabled:this.disabled,vertical:this.orientation==="vertical",summaryless:!this.hasSummarySlot,"hidden-label":this.hide})}" name="control" @slotchange="${h(this,y,k)}" ${p(i(this,c))}></slot><slot class="${a({summary:!0,error:this.error})}" name="summary" @slotchange="${h(this,b,q)}" ${p(i(this,f))}></slot></div><slot class="${a({description:!0,visible:this.hasDescriptionSlot,error:this.error,tooltip:this.hasTooltipSlot})}" id="description" name="description" @slotchange="${h(this,T,z)}" ${p(i(this,v))}></slot></div>`}};c=new WeakMap,d=new WeakMap,v=new WeakMap,f=new WeakMap,g=new WeakMap,y=new WeakSet,k=function(){$(i(this,c).value)},E=new WeakSet,D=function(){$(i(this,d).value)},T=new WeakSet,z=function(){const t=i(this,v).value?.assignedNodes({flatten:!0});this.hasDescriptionSlot=!!(t&&t.length>0)},b=new WeakSet,q=function(){const t=i(this,f).value?.assignedNodes({flatten:!0});this.hasSummarySlot=!!(t&&t.length>0)},M=new WeakSet,I=function(){const t=i(this,g).value?.assignedNodes({flatten:!0});this.hasTooltipSlot=!!(t&&t.length>0)},s.shadowRootOptions={...x.shadowRootOptions,mode:"closed"},s.styles=A,r([u({reflect:!0,type:Boolean})],s.prototype,"disabled",2),r([u({reflect:!0,type:Boolean})],s.prototype,"error",2),r([u({reflect:!0,type:Boolean})],s.prototype,"hide",2),r([u({reflect:!0})],s.prototype,"orientation",2),r([u({reflect:!0,type:Boolean})],s.prototype,"required",2),r([B()],s.prototype,"hasDescriptionSlot",2),r([B()],s.prototype,"hasSummarySlot",2),r([B()],s.prototype,"hasTooltipSlot",2),s=r([j("glide-core-label")],s);export{s as default};
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -0,0 +1,154 @@
1
+ "use strict";import{css as e}from"lit";import o from"./styles/visually-hidden.js";export default[e`
2
+ .component {
3
+ &.horizontal {
4
+ column-gap: var(--glide-core-spacing-sm);
5
+ display: grid;
6
+
7
+ /*
8
+ Since 1fr is actually minmax(auto, 1fr), this explicit minmax will make it so
9
+ the first column is sized to its content, and the second column fills the rest
10
+ of the space.
11
+ */
12
+ grid-template-columns: auto minmax(0, 1fr);
13
+ }
14
+
15
+ &.vertical {
16
+ display: flex;
17
+ flex-direction: column;
18
+ }
19
+
20
+ &.hidden-label {
21
+ display: flex;
22
+ flex-direction: column;
23
+ }
24
+ }
25
+
26
+ .tooltip-and-label {
27
+ align-items: center;
28
+ column-gap: var(--glide-core-spacing-xs);
29
+ display: flex;
30
+
31
+ &.hidden {
32
+ ${o};
33
+ }
34
+ }
35
+
36
+ glide-core-tooltip {
37
+ display: none;
38
+
39
+ &.vertical {
40
+ order: 1;
41
+ }
42
+
43
+ &.visible {
44
+ /*
45
+ The default is "display: content". But "order" does not work with
46
+ "display: content" and "order" is needed above.
47
+ */
48
+ display: block;
49
+ }
50
+ }
51
+
52
+ .tooltip-target {
53
+ background-color: transparent;
54
+ border: none;
55
+
56
+ /* TODO
57
+ We want the focus outline to wrap neatly around the trigger. Tooltip should
58
+ probably wrap its default slot in a SPAN with "tabindex=0" and include the
59
+ below styles so every consumer doesn't have to.
60
+ */
61
+ border-radius: 50%;
62
+ color: var(--glide-core-text-body-1);
63
+
64
+ /*
65
+ Any "display" that's not inline-level will do. We don't want the button to
66
+ acquire a line box, which will make it taller than its content and thus
67
+ make it difficult to center vertically with the label.
68
+ */
69
+ display: flex;
70
+ outline-offset: 1px;
71
+ padding: 0;
72
+ }
73
+
74
+ .label {
75
+ color: var(--glide-core-text-body-1);
76
+ display: block;
77
+ font-family: var(--glide-core-heading-xxxs-font-family);
78
+ font-size: var(--glide-core-heading-xxxs-font-size);
79
+ font-style: var(--glide-core-heading-xxxs-font-style);
80
+ font-variant: var(--glide-core-heading-xxxs-font-variant);
81
+ font-weight: var(--glide-core-heading-xxxs-font-weight);
82
+ line-height: 100%;
83
+ user-select: none;
84
+
85
+ &.disabled ::slotted(*) {
86
+ cursor: not-allowed;
87
+ }
88
+
89
+ &.horizontal {
90
+ line-height: 100%;
91
+ }
92
+
93
+ &.vertical {
94
+ margin-block-end: var(--glide-core-spacing-xxs);
95
+ }
96
+ }
97
+
98
+ .required-symbol {
99
+ color: var(--glide-core-status-error);
100
+ }
101
+
102
+ .control-and-summary {
103
+ align-items: center;
104
+ display: flex;
105
+ gap: var(--glide-core-spacing-sm);
106
+ }
107
+
108
+ .control {
109
+ display: block;
110
+
111
+ &.summaryless {
112
+ flex-grow: 1;
113
+ }
114
+
115
+ &.disabled::slotted(*) {
116
+ cursor: not-allowed;
117
+ }
118
+
119
+ &.vertical:not(.hidden-label) {
120
+ margin-block-start: var(--glide-core-spacing-xxs);
121
+ }
122
+ }
123
+
124
+ .summary {
125
+ font-family: var(--glide-core-body-sm-font-family);
126
+ font-size: var(--glide-core-body-sm-font-size);
127
+ font-style: var(--glide-core-body-sm-font-style);
128
+ font-weight: var(--glide-core-body-sm-font-weight);
129
+
130
+ &.error {
131
+ color: var(--glide-core-status-error);
132
+ }
133
+ }
134
+
135
+ .description {
136
+ color: var(--glide-core-text-body-1);
137
+ display: none;
138
+ font-family: var(--glide-core-body-xs-font-family);
139
+ font-size: var(--glide-core-body-xs-font-size);
140
+ font-style: var(--glide-core-body-xs-font-style);
141
+ font-weight: var(--glide-core-body-xs-font-weight);
142
+ grid-column: 2;
143
+ line-height: var(--glide-core-body-xs-line-height);
144
+ margin-block-start: var(--glide-core-spacing-xxs);
145
+
146
+ &.error {
147
+ color: var(--glide-core-status-error);
148
+ }
149
+
150
+ &.visible {
151
+ display: block;
152
+ }
153
+ }
154
+ `];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export default function (callback: () => Promise<unknown>): Promise<void>;
@@ -0,0 +1 @@
1
+ "use strict";import{ArgumentError as e}from"ow";import{expect as i}from"@open-wc/testing";import c from"sinon";export default async function(r){const n=window.onerror;window.onerror=null;const o=c.spy();try{await r.call(context)}catch(t){t instanceof e&&o()}i(o.called).to.be.true,window.onerror=n}
@@ -0,0 +1,16 @@
1
+ import { type Ow } from 'ow';
2
+ /**
3
+ * @description Asserts that a slot has at least one slotted node.
4
+ *
5
+ * @param slot - The slot to assert against.
6
+ */
7
+ export declare function owSlot(slot?: HTMLSlotElement): void;
8
+ /**
9
+ * @description Asserts that slotted nodes are a certain type.
10
+ *
11
+ * @param slot - The slot to assert against.
12
+ * @param slotted - An array of constructors. Slotted nodes must extend one of them.
13
+ */
14
+ export declare function owSlotType(slot?: HTMLSlotElement, slotted?: (typeof Element | typeof Text)[]): void;
15
+ declare const owOrShim: Ow;
16
+ export default owOrShim;
@@ -0,0 +1 @@
1
+ "use strict";import e from"ow";const i=window.location.host.startsWith("localhost")||window.location.host.startsWith("127.0.0.1");export function owSlot(o){i&&(e(o,e.object.is(t=>t instanceof HTMLSlotElement)),e(o.assignedNodes().length,e.number.is(t=>t>0).message(o.name?`Expected a "${o.name}" slot.`:"Expected a default slot.")))}export function owSlotType(o,t=[]){if(i&&(e(o,e.object.is(s=>s instanceof HTMLSlotElement)),o.assignedNodes().length!==0&&t.length>0)){const s=o.assignedNodes({flatten:!0}).filter(n=>n instanceof Text&&t.includes(Text)?!0:!(n instanceof Text));e(s.length,e.number.is(n=>n>0).message(`Expected a slotted node that extends ${t.map(({name:n})=>n).join(" or ")}.`));for(const n of s){const c=`Expected slotted node to extend ${t.map(({name:a})=>a).join(" or ")}. Extends ${n.constructor.name} instead.`,l=t.some(a=>n instanceof a);e(l,e.boolean.true.message(c))}}}const r=new Proxy(()=>{},{get:()=>r,apply:()=>r}),m=i?e:r;export default m;
@@ -0,0 +1,4 @@
1
+ import { LitElement } from 'lit';
2
+ export default class GlideCoreSlot extends LitElement {
3
+ render(): any;
4
+ }
@@ -0,0 +1,21 @@
1
+ import { LitElement } from 'lit';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'glide-core-menu-button': GlideCoreMenuButton;
5
+ }
6
+ }
7
+ /**
8
+ * @description A button for use within a <glide-core-menu>.
9
+ *
10
+ * @slot icon - An icon.
11
+ */
12
+ export default class GlideCoreMenuButton extends LitElement {
13
+ #private;
14
+ static shadowRootOptions: ShadowRootInit;
15
+ static styles: import("lit").CSSResult[];
16
+ label?: string;
17
+ privateActive: boolean;
18
+ privateIsFocused: boolean;
19
+ focus(): void;
20
+ render(): import("lit").TemplateResult<1>;
21
+ }
@@ -0,0 +1 @@
1
+ "use strict";var y=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var c=(e,t,o,a)=>{for(var i=a>1?void 0:a?E(t,o):t,p=e.length-1,f;p>=0;p--)(f=e[p])&&(i=(a?f(t,o,i):f(i))||i);return a&&i&&y(t,o,i),i};var u=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var v=(e,t,o)=>(u(e,t,"read from private field"),o?o.call(e):t.get(e)),m=(e,t,o)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,o)};var d=(e,t,o)=>(u(e,t,"access private method"),o);var r,l,$,n,g;import{LitElement as h,html as F}from"lit";import{classMap as R}from"lit/directives/class-map.js";import{createRef as I,ref as w}from"lit/directives/ref.js";import{customElement as x,property as b}from"lit/decorators.js";import A from"./menu.button.styles.js";let s=class extends h{constructor(){super(...arguments);m(this,l);m(this,n);this.privateActive=!1;this.privateIsFocused=!1;m(this,r,I())}focus(){v(this,r).value?.focus()}render(){return F`<button class="${R({component:!0,"component-active":this.privateActive})}" data-test="component" role="menuitem" tabindex="${this.privateActive?"0":"-1"}" type="button" @focusin="${d(this,l,$)}" @focusout="${d(this,n,g)}" ${w(v(this,r))}><slot name="icon"></slot>${this.label}</button>`}};r=new WeakMap,l=new WeakSet,$=function(){this.privateIsFocused=!0},n=new WeakSet,g=function(){this.privateIsFocused=!1},s.shadowRootOptions={...h.shadowRootOptions,mode:"closed"},s.styles=A,c([b({reflect:!0})],s.prototype,"label",2),c([b({type:Boolean})],s.prototype,"privateActive",2),s=c([x("glide-core-menu-button")],s);export{s as default};
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -0,0 +1,20 @@
1
+ "use strict";import{css as e}from"lit";export default[e`
2
+ .component {
3
+ align-items: center;
4
+ background-color: transparent;
5
+ border: none;
6
+ border-radius: var(--glide-core-spacing-sm);
7
+ cursor: pointer;
8
+ display: flex;
9
+ font: inherit;
10
+ gap: var(--gap);
11
+ inline-size: 100%;
12
+ padding-block: var(--padding-block);
13
+ padding-inline: var(--padding-inline);
14
+ user-select: none;
15
+
16
+ &.component-active {
17
+ background-color: var(--glide-core-surface-hover);
18
+ }
19
+ }
20
+ `];
@@ -0,0 +1 @@
1
+ export {};
package/dist/menu.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { LitElement } from 'lit';
2
+ import { type Placement } from '@floating-ui/dom';
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ 'glide-core-menu': GlideCoreMenu;
6
+ }
7
+ }
8
+ /**
9
+ * @description A basic menu.
10
+ *
11
+ * @slot - One or more of <glide-core-menu-link> or <glide-core-menu-button>.
12
+ * @slot target - A focusable element against which Menu will be positioned. Opens and closes Menu when interacted with.
13
+ */
14
+ export default class GlideCoreMenu extends LitElement {
15
+ #private;
16
+ static shadowRootOptions: ShadowRootInit;
17
+ static styles: import("lit").CSSResult[];
18
+ get open(): boolean;
19
+ set open(isOpen: boolean);
20
+ placement: Placement;
21
+ size: 'small' | 'large';
22
+ connectedCallback(): void;
23
+ disconnectedCallback(): void;
24
+ firstUpdated(): void;
25
+ focus(): void;
26
+ render(): import("lit").TemplateResult<1>;
27
+ }
package/dist/menu.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var et=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var g=(n,a,t,i)=>{for(var r=i>1?void 0:i?it(a,t):a,o=n.length-1,F;o>=0;o--)(F=n[o])&&(r=(i?F(a,t,r):F(r))||r);return i&&r&&et(a,t,r),r};var z=(n,a,t)=>{if(!a.has(n))throw TypeError("Cannot "+t)};var e=(n,a,t)=>(z(n,a,"read from private field"),t?t.call(n):a.get(n)),s=(n,a,t)=>{if(a.has(n))throw TypeError("Cannot add the same private member more than once");a instanceof WeakSet?a.add(n):a.set(n,t)},B=(n,a,t,i)=>(z(n,a,"write to private field"),i?i.call(n,t):a.set(n,t),t);var l=(n,a,t)=>(z(n,a,"access private method"),t);var y,D,m,E,h,v,k,w,N,L,J,U,Q,C,W,K,X,S,Y,R,Z,H,_,M,G,P,tt,p,u,A,j,c,f;import{LitElement as V,html as ot}from"lit";import{autoUpdate as st,computePosition as at,flip as nt,offset as rt}from"@floating-ui/dom";import{classMap as lt}from"lit/directives/class-map.js";import{createRef as T,ref as $}from"lit/directives/ref.js";import{customElement as ct,property as I}from"lit/decorators.js";import{owSlot as b,owSlotType as q}from"./library/ow.js";import x from"./menu.button.js";import O from"./menu.link.js";import pt from"./menu.styles.js";let d=class extends V{constructor(){super(...arguments);s(this,w);s(this,L);s(this,U);s(this,C);s(this,K);s(this,S);s(this,R);s(this,H);s(this,M);s(this,P);s(this,p);s(this,A);s(this,c);this.placement="bottom-start";this.size="large";s(this,y,void 0);s(this,D,T());s(this,m,T());s(this,E,!1);s(this,h,T());s(this,v,T());s(this,k,t=>{t.target&&this.contains(t.target)||(this.open=!1)})}get open(){return e(this,E)}set open(t){var i;B(this,E,t),t?l(this,A,j).call(this):(i=e(this,y))==null||i.call(this),e(this,c,f)&&(e(this,c,f).ariaExpanded=t?"true":"false")}connectedCallback(){super.connectedCallback(),document.addEventListener("click",e(this,k),{capture:!0})}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",e(this,k),{capture:!0})}firstUpdated(){b(e(this,m).value),b(e(this,v).value),q(e(this,m).value,[x,O,Text]),l(this,A,j).call(this);const t=e(this,p,u).at(0);t&&(t.privateActive=!0),e(this,c,f)&&e(this,h).value&&(e(this,c,f).ariaHasPopup="true",e(this,c,f).ariaExpanded=this.open?"true":"false")}focus(){const t=e(this,v).value?.assignedElements().at(0);t&&"focus"in t&&t?.focus()}render(){return ot`<div @focusout="${l(this,S,Y)}" @keydown="${l(this,R,Z)}" ${$(e(this,D))} class="component"><div class="target-container" @click="${l(this,H,_)}" @keydown="${l(this,M,G)}" id="target-container"><slot name="target" @slotchange="${l(this,P,tt)}" ${$(e(this,v))}></slot></div><div aria-labelledby="target-container" class="${lt({options:!0,large:this.size==="large",small:this.size==="small",visible:this.open})}" role="menu" ${$(e(this,h))}><slot @click="${l(this,U,Q)}" @keydown="${l(this,C,W)}" @mouseover="${l(this,K,X)}" @slotchange="${l(this,L,J)}" ${$(e(this,m))}></slot></div></div>`}};y=new WeakMap,D=new WeakMap,m=new WeakMap,E=new WeakMap,h=new WeakMap,v=new WeakMap,k=new WeakMap,w=new WeakSet,N=async function(){const t=e(this,p,u).find(i=>i.privateActive);t&&(await this.updateComplete,t.focus())},L=new WeakSet,J=function(){b(e(this,m).value),q(e(this,m).value,[x,O,Text])},U=new WeakSet,Q=function(){this.open=!1},C=new WeakSet,W=function(t){if([" ","Enter"].includes(t.key)){this.open=!1,this.focus();return}const i=e(this,p,u).findIndex(o=>o.privateActive),r=e(this,p,u).at(i);if(r){if(t.key==="ArrowUp"&&!t.metaKey){t.preventDefault();const o=e(this,p,u).at(i-1);o&&i!==0&&(r.privateActive=!1,o.privateActive=!0,o.focus());return}if(t.key==="ArrowDown"&&!t.metaKey){t.preventDefault();const o=e(this,p,u).at(i+1);o&&(r.privateActive=!1,o.privateActive=!0,o.focus());return}if(t.key==="ArrowUp"&&t.metaKey||t.key==="Home"||t.key==="PageUp"){t.preventDefault();const o=e(this,p,u).at(0);o&&(r.privateActive=!1,o.privateActive=!0,o.focus());return}if(t.key==="ArrowDown"&&t.metaKey||t.key==="End"||t.key==="PageDown"){t.preventDefault();const o=e(this,p,u).at(-1);o&&(r.privateActive=!1,o.privateActive=!0,o.focus());return}}},K=new WeakSet,X=function(t){if(t.target instanceof O||t.target instanceof x){for(const i of e(this,p,u))i.privateActive=i===t.target;t.target.focus()}},S=new WeakSet,Y=function(){setTimeout(()=>{e(this,p,u).some(({privateIsFocused:i})=>i)||(this.open=!1)})},R=new WeakSet,Z=function(t){t.key==="Escape"&&(this.open=!1,this.focus())},H=new WeakSet,_=function(){e(this,c,f)instanceof HTMLElement&&(e(this,c,f).ariaExpanded=this.open?"true":"false"),this.open=!this.open,this.open?l(this,w,N).call(this):this.focus()},M=new WeakSet,G=function(t){[" ","ArrowUp","ArrowDown"].includes(t.key)&&(t.preventDefault(),this.open=!0,l(this,w,N).call(this))},P=new WeakSet,tt=function(){b(e(this,v).value)},p=new WeakSet,u=function(){return(e(this,m).value?.assignedElements({flatten:!0})??[]).filter(t=>t instanceof O||t instanceof x)},A=new WeakSet,j=function(){e(this,c,f)&&e(this,h).value&&B(this,y,st(e(this,c,f),e(this,h).value,()=>{(async()=>{if(e(this,c,f)&&e(this,h).value){const{x:t,y:i,placement:r}=await at(e(this,c,f),e(this,h).value,{placement:this.placement,middleware:[rt({mainAxis:Number.parseFloat(window.getComputedStyle(document.body).getPropertyValue("--glide-core-spacing-xxs"))*16}),nt()]});e(this,h).value.dataset.placement=r,Object.assign(e(this,h).value.style,{left:`${t}px`,top:`${i}px`})}})()}))},c=new WeakSet,f=function(){return e(this,v).value?.assignedElements().at(0)},d.shadowRootOptions={...V.shadowRootOptions,mode:"closed"},d.styles=pt,g([I({reflect:!0,type:Boolean})],d.prototype,"open",1),g([I({reflect:!0})],d.prototype,"placement",2),g([I({reflect:!0})],d.prototype,"size",2),d=g([ct("glide-core-menu")],d);export{d as default};
@@ -0,0 +1,22 @@
1
+ import { LitElement } from 'lit';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'glide-core-menu-link': GlideCoreMenuLink;
5
+ }
6
+ }
7
+ /**
8
+ * @description A link for use within a <glide-core-menu>.
9
+ *
10
+ * @slot icon - An icon.
11
+ */
12
+ export default class GlideCoreMenuLink extends LitElement {
13
+ #private;
14
+ static shadowRootOptions: ShadowRootInit;
15
+ static styles: import("lit").CSSResult[];
16
+ label?: string;
17
+ url?: string;
18
+ privateActive: boolean;
19
+ privateIsFocused: boolean;
20
+ focus(): void;
21
+ render(): import("lit").TemplateResult<1>;
22
+ }
@@ -0,0 +1 @@
1
+ "use strict";var F=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var a=(e,t,o,c)=>{for(var r=c>1?void 0:c?R(t,o):t,f=e.length-1,n;f>=0;f--)(n=e[f])&&(r=(c?n(t,o,r):n(r))||r);return c&&r&&F(t,o,r),r};var d=(e,t,o)=>{if(!t.has(e))throw TypeError("Cannot "+o)};var u=(e,t,o)=>(d(e,t,"read from private field"),o?o.call(e):t.get(e)),m=(e,t,o)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,o)};var h=(e,t,o)=>(d(e,t,"access private method"),o);var i,l,g,p,E;import{LitElement as $,html as b}from"lit";import{classMap as y}from"lit/directives/class-map.js";import{createRef as I,ref as w}from"lit/directives/ref.js";import{customElement as x,property as v}from"lit/decorators.js";import{ifDefined as A}from"lit/directives/if-defined.js";import T from"./menu.link.styles.js";let s=class extends ${constructor(){super(...arguments);m(this,l);m(this,p);this.privateActive=!1;this.privateIsFocused=!1;m(this,i,I())}focus(){u(this,i).value?.focus()}render(){return b`<a class="${y({component:!0,"component-active":this.privateActive})}" data-test="component" href="${A(this.url)}" role="menuitem" tabindex="${this.privateActive?"0":"-1"}" @focusin="${h(this,l,g)}" @focusout="${h(this,p,E)}" ${w(u(this,i))}><slot name="icon"></slot>${this.label}</a>`}};i=new WeakMap,l=new WeakSet,g=function(){this.privateIsFocused=!0},p=new WeakSet,E=function(){this.privateIsFocused=!1},s.shadowRootOptions={...$.shadowRootOptions,mode:"closed"},s.styles=T,a([v({reflect:!0})],s.prototype,"label",2),a([v({reflect:!0})],s.prototype,"url",2),a([v({type:Boolean})],s.prototype,"privateActive",2),s=a([x("glide-core-menu-link")],s);export{s as default};
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -0,0 +1,22 @@
1
+ "use strict";import{css as e}from"lit";export default[e`
2
+ .component {
3
+ align-items: center;
4
+ background-color: transparent;
5
+ border: none;
6
+ border-radius: var(--glide-core-spacing-sm);
7
+ box-sizing: border-box;
8
+ color: inherit;
9
+ display: flex;
10
+ font: inherit;
11
+ gap: var(--gap);
12
+ inline-size: 100%;
13
+ padding-block: var(--padding-block);
14
+ padding-inline: var(--padding-inline);
15
+ text-decoration: none;
16
+ user-select: none;
17
+
18
+ &.component-active {
19
+ background-color: var(--glide-core-surface-hover);
20
+ }
21
+ }
22
+ `];
@@ -0,0 +1 @@
1
+ export {};