@redvars/peacock 3.6.2 → 3.7.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 (200) hide show
  1. package/dist/ButtonConstants-D06bY4uy.js +114 -0
  2. package/dist/ButtonConstants-D06bY4uy.js.map +1 -0
  3. package/dist/{BaseHyperlinkMixin-BNuwbiEf.js → NativeHyperlinkMixin-DrYXyfMQ.js} +8 -10
  4. package/dist/NativeHyperlinkMixin-DrYXyfMQ.js.map +1 -0
  5. package/dist/assets/components.css +1 -1
  6. package/dist/assets/components.css.map +1 -1
  7. package/dist/assets/styles.css +1 -1
  8. package/dist/assets/styles.css.map +1 -1
  9. package/dist/button-colors-Dwnez1tR.js +586 -0
  10. package/dist/button-colors-Dwnez1tR.js.map +1 -0
  11. package/dist/button-group.js +8 -8
  12. package/dist/button-group.js.map +1 -1
  13. package/dist/button.js +236 -133
  14. package/dist/button.js.map +1 -1
  15. package/dist/calendar-column-view.js +0 -1
  16. package/dist/calendar-column-view.js.map +1 -1
  17. package/dist/calendar-month-view.js +0 -1
  18. package/dist/calendar-month-view.js.map +1 -1
  19. package/dist/canvas.js +126 -107
  20. package/dist/canvas.js.map +1 -1
  21. package/dist/card-content.js +0 -1
  22. package/dist/card-content.js.map +1 -1
  23. package/dist/card.js +96 -90
  24. package/dist/card.js.map +1 -1
  25. package/dist/cb-compound-expression.js +4 -1
  26. package/dist/cb-compound-expression.js.map +1 -1
  27. package/dist/cb-divider.js +0 -1
  28. package/dist/cb-divider.js.map +1 -1
  29. package/dist/cb-expression.js +0 -2
  30. package/dist/cb-expression.js.map +1 -1
  31. package/dist/cb-predicate.js +0 -1
  32. package/dist/cb-predicate.js.map +1 -1
  33. package/dist/code-highlighter.js +23 -6
  34. package/dist/code-highlighter.js.map +1 -1
  35. package/dist/custom-elements-jsdocs.json +5079 -17882
  36. package/dist/custom-elements.json +19272 -19314
  37. package/dist/fab.js +181 -117
  38. package/dist/fab.js.map +1 -1
  39. package/dist/flow-designer.js +4 -4
  40. package/dist/icon-button-DJ0kZXYr.js +318 -0
  41. package/dist/icon-button-DJ0kZXYr.js.map +1 -0
  42. package/dist/index.js +7 -7
  43. package/dist/{navigation-rail-CD7IrqbN.js → navigation-rail-CM_svs5_.js} +1311 -730
  44. package/dist/navigation-rail-CM_svs5_.js.map +1 -0
  45. package/dist/observe-slot-change-D8Xg-kSS.js +60 -0
  46. package/dist/observe-slot-change-D8Xg-kSS.js.map +1 -0
  47. package/dist/peacock-loader.js +10 -7
  48. package/dist/peacock-loader.js.map +1 -1
  49. package/dist/popover-content.js +0 -1
  50. package/dist/popover-content.js.map +1 -1
  51. package/dist/search.js +15 -15
  52. package/dist/search.js.map +1 -1
  53. package/dist/src/__controllers/attachable-controller.d.ts +109 -0
  54. package/dist/src/__mixins/{BaseButtonMixin.d.ts → NativeButtonMixin.d.ts} +3 -3
  55. package/dist/src/__mixins/{BaseHyperlinkMixin.d.ts → NativeHyperlinkMixin.d.ts} +3 -4
  56. package/dist/src/__utils/is-link.d.ts +1 -0
  57. package/dist/src/__utils/observe-slot-change.d.ts +1 -1
  58. package/dist/src/accordion/accordion-item.d.ts +0 -1
  59. package/dist/src/breadcrumb/breadcrumb-item/breadcrumb-item.d.ts +0 -1
  60. package/dist/src/button/ButtonConstants.d.ts +1 -0
  61. package/dist/src/button/GroupButtonInterface.d.ts +4 -0
  62. package/dist/src/button/button/button.d.ts +32 -7
  63. package/dist/src/button/button-group/button-group.d.ts +2 -1
  64. package/dist/src/button/icon-button/icon-button.d.ts +26 -5
  65. package/dist/src/button/index.d.ts +1 -1
  66. package/dist/src/calendar/calendar-column-view.d.ts +0 -1
  67. package/dist/src/calendar/calendar-month-view.d.ts +0 -1
  68. package/dist/src/canvas/canvas.d.ts +3 -3
  69. package/dist/src/card/card-content.d.ts +0 -1
  70. package/dist/src/card/card.d.ts +9 -6
  71. package/dist/src/chip/chip/chip.d.ts +22 -3
  72. package/dist/src/condition-builder/cb-compound-expression.d.ts +0 -1
  73. package/dist/src/condition-builder/cb-divider.d.ts +0 -1
  74. package/dist/src/condition-builder/cb-expression.d.ts +0 -1
  75. package/dist/src/condition-builder/cb-predicate.d.ts +0 -1
  76. package/dist/src/fab/fab.d.ts +20 -6
  77. package/dist/src/field/field.d.ts +1 -0
  78. package/dist/src/focus-ring/focus-ring.d.ts +26 -20
  79. package/dist/src/image/image.d.ts +2 -2
  80. package/dist/src/index.d.ts +1 -0
  81. package/dist/src/input/input.d.ts +1 -3
  82. package/dist/src/item/index.d.ts +1 -0
  83. package/dist/src/item/item.d.ts +49 -0
  84. package/dist/src/link/link.d.ts +1 -1
  85. package/dist/src/list/list-item.d.ts +1 -2
  86. package/dist/src/menu/menu-item/menu-item.d.ts +9 -11
  87. package/dist/src/menu/sub-menu/sub-menu.d.ts +1 -1
  88. package/dist/src/navigation-rail/navigation-rail-item.d.ts +0 -2
  89. package/dist/src/navigation-rail/navigation-rail.d.ts +2 -6
  90. package/dist/src/popover/popover-content.d.ts +0 -1
  91. package/dist/src/ripple/ripple.d.ts +9 -1
  92. package/dist/src/search/search.d.ts +2 -6
  93. package/dist/src/segmented-button/segmented-button.d.ts +0 -1
  94. package/dist/src/select/option.d.ts +0 -1
  95. package/dist/src/sidebar-menu/sidebar-menu-item.d.ts +0 -1
  96. package/dist/src/sidebar-menu/sidebar-sub-menu.d.ts +0 -1
  97. package/dist/src/tabs/tab-panel.d.ts +0 -1
  98. package/dist/src/tabs/tab.d.ts +4 -6
  99. package/dist/test/item.test.d.ts +1 -0
  100. package/dist/tsconfig.tsbuildinfo +1 -1
  101. package/package.json +4 -2
  102. package/readme.md +2 -2
  103. package/scss/components.scss +0 -1
  104. package/scss/mixin.scss +33 -13
  105. package/scss/styles.scss +1 -3
  106. package/src/__controllers/attachable-controller.ts +198 -0
  107. package/src/__mixins/NativeButtonMixin.ts +87 -0
  108. package/src/__mixins/{BaseHyperlinkMixin.ts → NativeHyperlinkMixin.ts} +15 -15
  109. package/src/__utils/is-link.ts +3 -0
  110. package/src/__utils/observe-slot-change.ts +46 -14
  111. package/src/accordion/accordion-item.scss +1 -1
  112. package/src/accordion/accordion-item.ts +0 -1
  113. package/src/breadcrumb/breadcrumb-item/breadcrumb-item.ts +0 -1
  114. package/src/button/ButtonConstants.ts +1 -0
  115. package/src/button/GroupButtonInterface.ts +4 -0
  116. package/src/button/button/button-colors.scss +2 -2
  117. package/src/button/button/button-layers.scss +124 -0
  118. package/src/button/button/button-sizes.scss +31 -53
  119. package/src/button/button/button.scss +139 -262
  120. package/src/button/button/button.ts +260 -106
  121. package/src/button/button/only-button.scss +13 -0
  122. package/src/button/button-group/button-group.ts +59 -17
  123. package/src/button/icon-button/icon-button-sizes.scss +12 -27
  124. package/src/button/icon-button/icon-button.ts +191 -83
  125. package/src/button/index.ts +1 -1
  126. package/src/calendar/calendar-column-view.ts +0 -1
  127. package/src/calendar/calendar-month-view.ts +0 -1
  128. package/src/canvas/canvas.scss +18 -6
  129. package/src/canvas/canvas.ts +125 -103
  130. package/src/card/card-content.ts +2 -3
  131. package/src/card/card.scss +87 -95
  132. package/src/card/card.ts +62 -60
  133. package/src/chip/chip/chip.scss +66 -71
  134. package/src/chip/chip/chip.ts +155 -56
  135. package/src/code-highlighter/code-highlighter.scss +1 -1
  136. package/src/code-highlighter/code-highlighter.ts +20 -5
  137. package/src/condition-builder/cb-compound-expression.scss +4 -0
  138. package/src/condition-builder/cb-compound-expression.ts +0 -1
  139. package/src/condition-builder/cb-divider.ts +0 -1
  140. package/src/condition-builder/cb-expression.scss +0 -1
  141. package/src/condition-builder/cb-expression.ts +0 -1
  142. package/src/condition-builder/cb-predicate.ts +0 -1
  143. package/src/elevation/elevation.scss +5 -1
  144. package/src/empty-state/empty-state.scss +1 -0
  145. package/src/fab/fab-colors.scss +2 -2
  146. package/src/fab/fab-sizes.scss +24 -34
  147. package/src/fab/fab.scss +77 -71
  148. package/src/fab/fab.ts +141 -65
  149. package/src/field/field.ts +6 -0
  150. package/src/focus-ring/focus-ring.ts +81 -72
  151. package/src/image/image.scss +21 -16
  152. package/src/image/image.ts +13 -14
  153. package/src/index.ts +1 -0
  154. package/src/input/input.ts +16 -25
  155. package/src/item/index.ts +1 -0
  156. package/src/item/item.scss +195 -0
  157. package/src/item/item.ts +362 -0
  158. package/src/link/link.scss +1 -10
  159. package/src/link/link.ts +4 -2
  160. package/src/list/list-item.ts +8 -8
  161. package/src/menu/menu/menu.ts +5 -9
  162. package/src/menu/menu-item/menu-item.scss +30 -108
  163. package/src/menu/menu-item/menu-item.ts +102 -133
  164. package/src/menu/sub-menu/sub-menu.ts +6 -3
  165. package/src/navigation-rail/navigation-rail-item.scss +5 -0
  166. package/src/navigation-rail/navigation-rail-item.ts +10 -15
  167. package/src/navigation-rail/navigation-rail.ts +2 -6
  168. package/src/peacock-loader.ts +5 -1
  169. package/src/popover/popover-content.ts +0 -1
  170. package/src/ripple/ripple.ts +52 -20
  171. package/src/search/search.scss +3 -0
  172. package/src/search/search.ts +11 -16
  173. package/src/segmented-button/segmented-button.ts +0 -1
  174. package/src/select/option.ts +1 -2
  175. package/src/select/select.scss +1 -10
  176. package/src/select/select.ts +2 -0
  177. package/src/sidebar-menu/sidebar-menu-item.ts +0 -1
  178. package/src/sidebar-menu/sidebar-sub-menu.ts +0 -1
  179. package/src/skeleton/skeleton.scss +5 -1
  180. package/src/tabs/tab-panel.ts +0 -1
  181. package/src/tabs/tab.ts +60 -70
  182. package/src/text/text.css-component.scss +3 -21
  183. package/src/tooltip/tooltip.scss +5 -8
  184. package/src/tooltip/tooltip.ts +1 -2
  185. package/dist/BaseButton-BNFAYn-S.js +0 -219
  186. package/dist/BaseButton-BNFAYn-S.js.map +0 -1
  187. package/dist/BaseHyperlinkMixin-BNuwbiEf.js.map +0 -1
  188. package/dist/button-colors-AvGh22Zn.js +0 -561
  189. package/dist/button-colors-AvGh22Zn.js.map +0 -1
  190. package/dist/icon-button-ohxHhy4t.js +0 -247
  191. package/dist/icon-button-ohxHhy4t.js.map +0 -1
  192. package/dist/navigation-rail-CD7IrqbN.js.map +0 -1
  193. package/dist/observe-slot-change-BGJfgg2E.js +0 -31
  194. package/dist/observe-slot-change-BGJfgg2E.js.map +0 -1
  195. package/dist/src/button/BaseButton.d.ts +0 -28
  196. package/dist/src/focus-ring/FocusAttachableController.d.ts +0 -8
  197. package/src/__mixins/BaseButtonMixin.ts +0 -83
  198. package/src/button/BaseButton.ts +0 -113
  199. package/src/focus-ring/FocusAttachableController.ts +0 -28
  200. package/src/popover/tooltip.css-component.scss +0 -19
@@ -1,31 +0,0 @@
1
- function hasMeaningfulContent(slotElement) {
2
- const nodes = slotElement?.assignedNodes({ flatten: true }) || [];
3
- for (const node of nodes) {
4
- if (node.nodeType === Node.ELEMENT_NODE) {
5
- return true;
6
- }
7
- if (node.nodeType === Node.TEXT_NODE &&
8
- (node.textContent?.trim().length || 0) > 0) {
9
- return true;
10
- }
11
- }
12
- return false;
13
- }
14
- function observerSlotChangesWithCallback(slot, callback) {
15
- const observer = new MutationObserver(() => {
16
- callback(hasMeaningfulContent(slot));
17
- });
18
- const assignedNodes = slot?.assignedNodes({ flatten: true }) || [];
19
- assignedNodes.forEach(node => {
20
- observer.observe(node, {
21
- attributes: true,
22
- childList: true,
23
- characterData: true,
24
- subtree: true,
25
- });
26
- });
27
- callback(hasMeaningfulContent(slot));
28
- }
29
-
30
- export { observerSlotChangesWithCallback as o };
31
- //# sourceMappingURL=observe-slot-change-BGJfgg2E.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"observe-slot-change-BGJfgg2E.js","sources":["../../src/__utils/observe-slot-change.ts"],"sourcesContent":["function hasMeaningfulContent(slotElement: HTMLSlotElement | null) {\n const nodes = slotElement?.assignedNodes({ flatten: true }) || [];\n\n for (const node of nodes) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n return true;\n }\n if (\n node.nodeType === Node.TEXT_NODE &&\n (node.textContent?.trim().length || 0) > 0\n ) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function observerSlotChangesWithCallback(\n slot: HTMLSlotElement | null,\n callback: (hasContent: boolean) => void,\n) {\n const observer = new MutationObserver(() => {\n callback(hasMeaningfulContent(slot));\n });\n\n const assignedNodes = slot?.assignedNodes({ flatten: true }) || [];\n assignedNodes.forEach(node => {\n observer.observe(node, {\n attributes: true,\n childList: true,\n characterData: true,\n subtree: true,\n });\n });\n\n callback(hasMeaningfulContent(slot));\n}"],"names":[],"mappings":"AAAA,SAAS,oBAAoB,CAAC,WAAmC,EAAA;AAC/D,IAAA,MAAM,KAAK,GAAG,WAAW,EAAE,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;AAEjE,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,EAAE;AACvC,YAAA,OAAO,IAAI;QACb;AACA,QAAA,IACE,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,SAAS;AAChC,YAAA,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,EAC1C;AACA,YAAA,OAAO,IAAI;QACb;IACF;AAEA,IAAA,OAAO,KAAK;AACd;AAEM,SAAU,+BAA+B,CAC7C,IAA4B,EAC5B,QAAuC,EAAA;AAEvC,IAAA,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,MAAK;AACzC,QAAA,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACtC,IAAA,CAAC,CAAC;AAEF,IAAA,MAAM,aAAa,GAAG,IAAI,EAAE,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;AAClE,IAAA,aAAa,CAAC,OAAO,CAAC,IAAI,IAAG;AAC3B,QAAA,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;AACrB,YAAA,UAAU,EAAE,IAAI;AAChB,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,aAAa,EAAE,IAAI;AACnB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA,CAAC;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACtC;;;;"}
@@ -1,28 +0,0 @@
1
- import { LitElement, nothing } from 'lit';
2
- declare const BaseButton_base: typeof LitElement & import("../__mixins/MixinConstructor.js").MixinConstructor<import("@/__mixins/BaseHyperlinkMixin.js").BaseHyperlinkInterface> & import("../__mixins/MixinConstructor.js").MixinConstructor<import("@/__mixins/BaseButtonMixin.js").BaseButtonInterface>;
3
- export declare class BaseButton extends BaseButton_base {
4
- protected static readonly DISABLED_REASON_ID = "disabled-reason";
5
- color?: string;
6
- variant?: string;
7
- skeleton: boolean;
8
- toggle: boolean;
9
- selected: boolean;
10
- /**
11
- * Sets the delay for throttle in milliseconds. Defaults to 200 milliseconds.
12
- */
13
- throttleDelay: number;
14
- tooltip?: string;
15
- /**
16
- * States
17
- */
18
- isPressed: boolean;
19
- readonly buttonElement: HTMLElement | null;
20
- connectedCallback(): void;
21
- disconnectedCallback(): void;
22
- __handlePress: (event: KeyboardEvent | MouseEvent) => void;
23
- __dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void;
24
- __dispatchClick: (event: MouseEvent | KeyboardEvent) => void;
25
- __renderDisabledReason(softDisabled: boolean): typeof nothing | import("lit-html").TemplateResult<1>;
26
- __renderTooltip(): typeof nothing | import("lit-html").TemplateResult<1>;
27
- }
28
- export {};
@@ -1,8 +0,0 @@
1
- import { ReactiveController, ReactiveControllerHost } from 'lit';
2
- export declare class FocusAttachableController implements ReactiveController {
3
- host: ReactiveControllerHost;
4
- getControlElement: () => HTMLElement;
5
- visible: boolean;
6
- constructor(host: ReactiveControllerHost, getControlElement: () => HTMLElement);
7
- hostConnected(): void;
8
- }
@@ -1,83 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import { property } from 'lit/decorators.js';
3
- import type { MixinConstructor } from './MixinConstructor.js';
4
-
5
-
6
- /**
7
- * 1. Define an interface for the members the mixin adds.
8
- * This makes the type annotation much cleaner.
9
- */
10
- export interface BaseButtonInterface {
11
- htmlType: 'button' | 'submit' | 'reset';
12
- disabled: boolean;
13
- softDisabled: boolean;
14
- disabledReason: string;
15
- form: string;
16
- name: string;
17
- value: string;
18
- }
19
-
20
- /**
21
- * 2. Apply the type annotation to the variable.
22
- */
23
- const BaseButtonMixin: <T extends MixinConstructor<LitElement>>(superclass: T) => T & MixinConstructor<BaseButtonInterface> = <T extends MixinConstructor<LitElement>>(superclass: T) => {
24
- // Naming the class (BaseButtonElement) instead of using 'Mixin' or anonymous
25
- // prevents the "__childPart" visibility error.
26
- class BaseButtonElement extends superclass implements BaseButtonInterface {
27
-
28
- /**
29
- * The type of the underlying `<button>` element. Maps to the native `type` attribute.
30
- * Possible values are `"button"`, `"submit"`, `"reset"`. Defaults to `"button"`.
31
- */
32
- @property({ type: String }) htmlType: 'button' | 'submit' | 'reset' =
33
- 'button';
34
-
35
- /**
36
- * When `true`, the button is disabled and cannot be interacted with. Reflects to the `disabled` attribute. Defaults to `false`.
37
- */
38
- @property({ type: Boolean, reflect: true })
39
- disabled: boolean = false;
40
-
41
- /**
42
- * When `true`, the button is visually styled as disabled and cannot be interacted with, but remains focusable.
43
- * Use this in combination with `disabledReason` to communicate why the button is unavailable.
44
- * Reflects to the `soft-disabled` attribute. Defaults to `false`.
45
- */
46
- @property({ type: Boolean, reflect: true, attribute: 'soft-disabled' })
47
- softDisabled: boolean = false;
48
-
49
- /**
50
- * A human-readable explanation of why the button is disabled or soft-disabled.
51
- * Rendered as a visually hidden tooltip and linked via `aria-describedby` for accessibility.
52
- * Maps to the `disabled-reason` attribute.
53
- */
54
- @property({ attribute: 'disabled-reason' })
55
- disabledReason: string = '';
56
-
57
- /**
58
- * The `id` of the `<form>` element to associate the button with.
59
- * If omitted, the button is associated with its nearest ancestor form.
60
- * Maps to the native `form` attribute.
61
- */
62
- @property()
63
- form: string = '';
64
-
65
- /**
66
- * The name of the button, submitted as part of a name/value pair when the associated form is submitted.
67
- * Maps to the native `name` attribute.
68
- */
69
- @property()
70
- name: string = '';
71
-
72
- /**
73
- * The value of the button, submitted as part of a name/value pair when the associated form is submitted.
74
- * Maps to the native `value` attribute.
75
- */
76
- @property()
77
- value: string = '';
78
- }
79
-
80
- return BaseButtonElement as T & MixinConstructor<BaseButtonInterface>;
81
- };
82
-
83
- export default BaseButtonMixin;
@@ -1,113 +0,0 @@
1
- import { html, LitElement, nothing } from 'lit';
2
- import { property, query, state } from 'lit/decorators.js';
3
- import { dispatchActivationClick, isActivationClick } from '../__utils/dispatch-event-utils.js';
4
- import BaseHyperlinkMixin from '@/__mixins/BaseHyperlinkMixin.js';
5
- import BaseButtonMixin from '@/__mixins/BaseButtonMixin.js';
6
-
7
-
8
-
9
- export class BaseButton extends BaseButtonMixin(BaseHyperlinkMixin(LitElement)) {
10
- protected static readonly DISABLED_REASON_ID = 'disabled-reason';
11
-
12
-
13
- color?: string;
14
-
15
- variant?: string;
16
-
17
- @property({ type: Boolean, reflect: true }) skeleton: boolean = false;
18
-
19
- @property({ type: Boolean, reflect: true }) toggle: boolean = false;
20
-
21
- @property({ type: Boolean, reflect: true }) selected: boolean = false;
22
-
23
- /**
24
- * Sets the delay for throttle in milliseconds. Defaults to 200 milliseconds.
25
- */
26
- @property() throttleDelay = 200;
27
-
28
- @property() tooltip?: string;
29
-
30
- /**
31
- * States
32
- */
33
- @state()
34
- isPressed = false;
35
-
36
- @query('.button') readonly buttonElement!: HTMLElement | null;
37
-
38
- override connectedCallback() {
39
- super.connectedCallback();
40
- this.addEventListener('click', this.__dispatchClickWithThrottle);
41
- window.addEventListener('mouseup', this.__handlePress);
42
- }
43
-
44
- override disconnectedCallback() {
45
- window.removeEventListener('mouseup', this.__handlePress);
46
- this.removeEventListener('click', this.__dispatchClickWithThrottle);
47
- super.disconnectedCallback();
48
- }
49
-
50
- __handlePress = (event: KeyboardEvent | MouseEvent) => {
51
- if (this.disabled || this.skeleton || this.softDisabled) return;
52
- if (
53
- event instanceof KeyboardEvent &&
54
- event.type === 'keydown' &&
55
- (event.key === 'Enter' || event.key === ' ')
56
- ) {
57
- this.isPressed = true;
58
- } else if (event.type === 'mousedown') {
59
- this.isPressed = true;
60
- } else {
61
- this.isPressed = false;
62
- }
63
- };
64
-
65
- __dispatchClickWithThrottle: (event: MouseEvent | KeyboardEvent) => void =
66
- event => {
67
- this.__dispatchClick(event);
68
- };
69
-
70
- __dispatchClick = (event: MouseEvent | KeyboardEvent) => {
71
- // If the button is soft-disabled or a disabled link, we need to explicitly
72
- // prevent the click from propagating to other event listeners as well as
73
- // prevent the default action.
74
- if (this.softDisabled || (this.disabled && this.href) || this.skeleton) {
75
- event.stopImmediatePropagation();
76
- event.preventDefault();
77
- return;
78
- }
79
-
80
- if (!isActivationClick(event) || !this.buttonElement) {
81
- return;
82
- }
83
-
84
- if (this.toggle) {
85
- this.selected = !this.selected;
86
- }
87
-
88
- this.focus();
89
- dispatchActivationClick(this.buttonElement);
90
- };
91
-
92
-
93
-
94
- __renderDisabledReason(softDisabled: boolean) {
95
- if (softDisabled)
96
- return html`<div
97
- id=${BaseButton.DISABLED_REASON_ID}
98
- role="tooltip"
99
- aria-label=${this.disabledReason}
100
- class="screen-reader-only"
101
- >
102
- ${this.disabledReason}
103
- </div>`;
104
- return nothing;
105
- }
106
-
107
- __renderTooltip() {
108
- if (this.tooltip) {
109
- return html`<wc-tooltip for="button">${this.tooltip}</wc-tooltip>`;
110
- }
111
- return nothing;
112
- }
113
- }
@@ -1,28 +0,0 @@
1
- import { ReactiveController, ReactiveControllerHost } from 'lit';
2
-
3
- export class FocusAttachableController implements ReactiveController {
4
- host: ReactiveControllerHost;
5
-
6
- getControlElement: () => HTMLElement;
7
-
8
- visible = false;
9
-
10
- constructor(
11
- host: ReactiveControllerHost,
12
- getControlElement: () => HTMLElement,
13
- ) {
14
- (this.host = host).addController(this);
15
- this.getControlElement = getControlElement;
16
- }
17
-
18
- hostConnected() {
19
- if (this.getControlElement) {
20
- const element = this.getControlElement();
21
- element.addEventListener('focus', () => {
22
- // @ts-ignore
23
- this.host.handleEvent();
24
- this.host.requestUpdate();
25
- });
26
- }
27
- }
28
- }
@@ -1,19 +0,0 @@
1
- @use "../../scss/mixin";
2
- @use "sass:string";
3
-
4
- @include mixin.base-styles;
5
-
6
- .tooltip {
7
- display: inline-block;
8
- @include mixin.get-typography(body-small);
9
- max-width: 17.5rem;
10
- padding-inline: var(--spacing-100);
11
- padding-block: var(--spacing-050);
12
- color: var(--color-inverse-on-surface);
13
- background-color: var(--color-inverse-surface);
14
- border-radius: var(--shape-corner-extra-small);
15
- }
16
-
17
- .tooltip-link {
18
- border-bottom: 1px dashed var(--color-on-surface);
19
- }