@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.
- package/dist/ButtonConstants-D06bY4uy.js +114 -0
- package/dist/ButtonConstants-D06bY4uy.js.map +1 -0
- package/dist/{BaseHyperlinkMixin-BNuwbiEf.js → NativeHyperlinkMixin-DrYXyfMQ.js} +8 -10
- package/dist/NativeHyperlinkMixin-DrYXyfMQ.js.map +1 -0
- package/dist/assets/components.css +1 -1
- package/dist/assets/components.css.map +1 -1
- package/dist/assets/styles.css +1 -1
- package/dist/assets/styles.css.map +1 -1
- package/dist/button-colors-Dwnez1tR.js +586 -0
- package/dist/button-colors-Dwnez1tR.js.map +1 -0
- package/dist/button-group.js +8 -8
- package/dist/button-group.js.map +1 -1
- package/dist/button.js +236 -133
- package/dist/button.js.map +1 -1
- package/dist/calendar-column-view.js +0 -1
- package/dist/calendar-column-view.js.map +1 -1
- package/dist/calendar-month-view.js +0 -1
- package/dist/calendar-month-view.js.map +1 -1
- package/dist/canvas.js +126 -107
- package/dist/canvas.js.map +1 -1
- package/dist/card-content.js +0 -1
- package/dist/card-content.js.map +1 -1
- package/dist/card.js +96 -90
- package/dist/card.js.map +1 -1
- package/dist/cb-compound-expression.js +4 -1
- package/dist/cb-compound-expression.js.map +1 -1
- package/dist/cb-divider.js +0 -1
- package/dist/cb-divider.js.map +1 -1
- package/dist/cb-expression.js +0 -2
- package/dist/cb-expression.js.map +1 -1
- package/dist/cb-predicate.js +0 -1
- package/dist/cb-predicate.js.map +1 -1
- package/dist/code-highlighter.js +23 -6
- package/dist/code-highlighter.js.map +1 -1
- package/dist/custom-elements-jsdocs.json +5079 -17882
- package/dist/custom-elements.json +19272 -19314
- package/dist/fab.js +181 -117
- package/dist/fab.js.map +1 -1
- package/dist/flow-designer.js +4 -4
- package/dist/icon-button-DJ0kZXYr.js +318 -0
- package/dist/icon-button-DJ0kZXYr.js.map +1 -0
- package/dist/index.js +7 -7
- package/dist/{navigation-rail-CD7IrqbN.js → navigation-rail-CM_svs5_.js} +1311 -730
- package/dist/navigation-rail-CM_svs5_.js.map +1 -0
- package/dist/observe-slot-change-D8Xg-kSS.js +60 -0
- package/dist/observe-slot-change-D8Xg-kSS.js.map +1 -0
- package/dist/peacock-loader.js +10 -7
- package/dist/peacock-loader.js.map +1 -1
- package/dist/popover-content.js +0 -1
- package/dist/popover-content.js.map +1 -1
- package/dist/search.js +15 -15
- package/dist/search.js.map +1 -1
- package/dist/src/__controllers/attachable-controller.d.ts +109 -0
- package/dist/src/__mixins/{BaseButtonMixin.d.ts → NativeButtonMixin.d.ts} +3 -3
- package/dist/src/__mixins/{BaseHyperlinkMixin.d.ts → NativeHyperlinkMixin.d.ts} +3 -4
- package/dist/src/__utils/is-link.d.ts +1 -0
- package/dist/src/__utils/observe-slot-change.d.ts +1 -1
- package/dist/src/accordion/accordion-item.d.ts +0 -1
- package/dist/src/breadcrumb/breadcrumb-item/breadcrumb-item.d.ts +0 -1
- package/dist/src/button/ButtonConstants.d.ts +1 -0
- package/dist/src/button/GroupButtonInterface.d.ts +4 -0
- package/dist/src/button/button/button.d.ts +32 -7
- package/dist/src/button/button-group/button-group.d.ts +2 -1
- package/dist/src/button/icon-button/icon-button.d.ts +26 -5
- package/dist/src/button/index.d.ts +1 -1
- package/dist/src/calendar/calendar-column-view.d.ts +0 -1
- package/dist/src/calendar/calendar-month-view.d.ts +0 -1
- package/dist/src/canvas/canvas.d.ts +3 -3
- package/dist/src/card/card-content.d.ts +0 -1
- package/dist/src/card/card.d.ts +9 -6
- package/dist/src/chip/chip/chip.d.ts +22 -3
- package/dist/src/condition-builder/cb-compound-expression.d.ts +0 -1
- package/dist/src/condition-builder/cb-divider.d.ts +0 -1
- package/dist/src/condition-builder/cb-expression.d.ts +0 -1
- package/dist/src/condition-builder/cb-predicate.d.ts +0 -1
- package/dist/src/fab/fab.d.ts +20 -6
- package/dist/src/field/field.d.ts +1 -0
- package/dist/src/focus-ring/focus-ring.d.ts +26 -20
- package/dist/src/image/image.d.ts +2 -2
- package/dist/src/index.d.ts +1 -0
- package/dist/src/input/input.d.ts +1 -3
- package/dist/src/item/index.d.ts +1 -0
- package/dist/src/item/item.d.ts +49 -0
- package/dist/src/link/link.d.ts +1 -1
- package/dist/src/list/list-item.d.ts +1 -2
- package/dist/src/menu/menu-item/menu-item.d.ts +9 -11
- package/dist/src/menu/sub-menu/sub-menu.d.ts +1 -1
- package/dist/src/navigation-rail/navigation-rail-item.d.ts +0 -2
- package/dist/src/navigation-rail/navigation-rail.d.ts +2 -6
- package/dist/src/popover/popover-content.d.ts +0 -1
- package/dist/src/ripple/ripple.d.ts +9 -1
- package/dist/src/search/search.d.ts +2 -6
- package/dist/src/segmented-button/segmented-button.d.ts +0 -1
- package/dist/src/select/option.d.ts +0 -1
- package/dist/src/sidebar-menu/sidebar-menu-item.d.ts +0 -1
- package/dist/src/sidebar-menu/sidebar-sub-menu.d.ts +0 -1
- package/dist/src/tabs/tab-panel.d.ts +0 -1
- package/dist/src/tabs/tab.d.ts +4 -6
- package/dist/test/item.test.d.ts +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -2
- package/readme.md +2 -2
- package/scss/components.scss +0 -1
- package/scss/mixin.scss +33 -13
- package/scss/styles.scss +1 -3
- package/src/__controllers/attachable-controller.ts +198 -0
- package/src/__mixins/NativeButtonMixin.ts +87 -0
- package/src/__mixins/{BaseHyperlinkMixin.ts → NativeHyperlinkMixin.ts} +15 -15
- package/src/__utils/is-link.ts +3 -0
- package/src/__utils/observe-slot-change.ts +46 -14
- package/src/accordion/accordion-item.scss +1 -1
- package/src/accordion/accordion-item.ts +0 -1
- package/src/breadcrumb/breadcrumb-item/breadcrumb-item.ts +0 -1
- package/src/button/ButtonConstants.ts +1 -0
- package/src/button/GroupButtonInterface.ts +4 -0
- package/src/button/button/button-colors.scss +2 -2
- package/src/button/button/button-layers.scss +124 -0
- package/src/button/button/button-sizes.scss +31 -53
- package/src/button/button/button.scss +139 -262
- package/src/button/button/button.ts +260 -106
- package/src/button/button/only-button.scss +13 -0
- package/src/button/button-group/button-group.ts +59 -17
- package/src/button/icon-button/icon-button-sizes.scss +12 -27
- package/src/button/icon-button/icon-button.ts +191 -83
- package/src/button/index.ts +1 -1
- package/src/calendar/calendar-column-view.ts +0 -1
- package/src/calendar/calendar-month-view.ts +0 -1
- package/src/canvas/canvas.scss +18 -6
- package/src/canvas/canvas.ts +125 -103
- package/src/card/card-content.ts +2 -3
- package/src/card/card.scss +87 -95
- package/src/card/card.ts +62 -60
- package/src/chip/chip/chip.scss +66 -71
- package/src/chip/chip/chip.ts +155 -56
- package/src/code-highlighter/code-highlighter.scss +1 -1
- package/src/code-highlighter/code-highlighter.ts +20 -5
- package/src/condition-builder/cb-compound-expression.scss +4 -0
- package/src/condition-builder/cb-compound-expression.ts +0 -1
- package/src/condition-builder/cb-divider.ts +0 -1
- package/src/condition-builder/cb-expression.scss +0 -1
- package/src/condition-builder/cb-expression.ts +0 -1
- package/src/condition-builder/cb-predicate.ts +0 -1
- package/src/elevation/elevation.scss +5 -1
- package/src/empty-state/empty-state.scss +1 -0
- package/src/fab/fab-colors.scss +2 -2
- package/src/fab/fab-sizes.scss +24 -34
- package/src/fab/fab.scss +77 -71
- package/src/fab/fab.ts +141 -65
- package/src/field/field.ts +6 -0
- package/src/focus-ring/focus-ring.ts +81 -72
- package/src/image/image.scss +21 -16
- package/src/image/image.ts +13 -14
- package/src/index.ts +1 -0
- package/src/input/input.ts +16 -25
- package/src/item/index.ts +1 -0
- package/src/item/item.scss +195 -0
- package/src/item/item.ts +362 -0
- package/src/link/link.scss +1 -10
- package/src/link/link.ts +4 -2
- package/src/list/list-item.ts +8 -8
- package/src/menu/menu/menu.ts +5 -9
- package/src/menu/menu-item/menu-item.scss +30 -108
- package/src/menu/menu-item/menu-item.ts +102 -133
- package/src/menu/sub-menu/sub-menu.ts +6 -3
- package/src/navigation-rail/navigation-rail-item.scss +5 -0
- package/src/navigation-rail/navigation-rail-item.ts +10 -15
- package/src/navigation-rail/navigation-rail.ts +2 -6
- package/src/peacock-loader.ts +5 -1
- package/src/popover/popover-content.ts +0 -1
- package/src/ripple/ripple.ts +52 -20
- package/src/search/search.scss +3 -0
- package/src/search/search.ts +11 -16
- package/src/segmented-button/segmented-button.ts +0 -1
- package/src/select/option.ts +1 -2
- package/src/select/select.scss +1 -10
- package/src/select/select.ts +2 -0
- package/src/sidebar-menu/sidebar-menu-item.ts +0 -1
- package/src/sidebar-menu/sidebar-sub-menu.ts +0 -1
- package/src/skeleton/skeleton.scss +5 -1
- package/src/tabs/tab-panel.ts +0 -1
- package/src/tabs/tab.ts +60 -70
- package/src/text/text.css-component.scss +3 -21
- package/src/tooltip/tooltip.scss +5 -8
- package/src/tooltip/tooltip.ts +1 -2
- package/dist/BaseButton-BNFAYn-S.js +0 -219
- package/dist/BaseButton-BNFAYn-S.js.map +0 -1
- package/dist/BaseHyperlinkMixin-BNuwbiEf.js.map +0 -1
- package/dist/button-colors-AvGh22Zn.js +0 -561
- package/dist/button-colors-AvGh22Zn.js.map +0 -1
- package/dist/icon-button-ohxHhy4t.js +0 -247
- package/dist/icon-button-ohxHhy4t.js.map +0 -1
- package/dist/navigation-rail-CD7IrqbN.js.map +0 -1
- package/dist/observe-slot-change-BGJfgg2E.js +0 -31
- package/dist/observe-slot-change-BGJfgg2E.js.map +0 -1
- package/dist/src/button/BaseButton.d.ts +0 -28
- package/dist/src/focus-ring/FocusAttachableController.d.ts +0 -8
- package/src/__mixins/BaseButtonMixin.ts +0 -83
- package/src/button/BaseButton.ts +0 -113
- package/src/focus-ring/FocusAttachableController.ts +0 -28
- package/src/popover/tooltip.css-component.scss +0 -19
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@redvars/peacock",
|
|
3
3
|
"description": "The foundation for beautiful user interfaces",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.7.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"module": "dist/index.js",
|
|
@@ -41,13 +41,14 @@
|
|
|
41
41
|
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\""
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
+
"@floating-ui/dom": "^1.7.5",
|
|
45
|
+
"@pierre/theme": "^0.0.29",
|
|
44
46
|
"@tiptap/core": "^2.11.3",
|
|
45
47
|
"@tiptap/extension-mention": "^2.11.3",
|
|
46
48
|
"@tiptap/extension-placeholder": "^2.11.3",
|
|
47
49
|
"@tiptap/extension-underline": "^2.11.3",
|
|
48
50
|
"@tiptap/pm": "^2.11.3",
|
|
49
51
|
"@tiptap/starter-kit": "^2.11.3",
|
|
50
|
-
"@floating-ui/dom": "^1.7.5",
|
|
51
52
|
"@types/prettier": "^3.0.0",
|
|
52
53
|
"d3": "^7.9.0",
|
|
53
54
|
"install": "^0.13.0",
|
|
@@ -78,6 +79,7 @@
|
|
|
78
79
|
"@wc-toolkit/jsdoc-tags": "^1.1.0",
|
|
79
80
|
"@web/dev-server": "^0.4.6",
|
|
80
81
|
"@web/test-runner": "^0.18.2",
|
|
82
|
+
"cem-plugin-expanded-types": "^1.4.0",
|
|
81
83
|
"concurrently": "^8.2.2",
|
|
82
84
|
"eslint": "^8.57.0",
|
|
83
85
|
"eslint-config-prettier": "^9.1.0",
|
package/readme.md
CHANGED
|
@@ -44,9 +44,9 @@ Visit [https://peacock.redvars.com](https://peacock.redvars.com) to view the doc
|
|
|
44
44
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
45
45
|
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@100..900&family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
|
|
46
46
|
|
|
47
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@redvars/peacock@3.
|
|
47
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@redvars/peacock@3.7.0/dist/assets/styles.css"></link>
|
|
48
48
|
<script type='module'
|
|
49
|
-
src='https://cdn.jsdelivr.net/npm/@redvars/peacock@3.
|
|
49
|
+
src='https://cdn.jsdelivr.net/npm/@redvars/peacock@3.7.0/dist/peacock-loader.js'></script>
|
|
50
50
|
</head>
|
|
51
51
|
|
|
52
52
|
<wc-button>Button</wc-button>
|
package/scss/components.scss
CHANGED
package/scss/mixin.scss
CHANGED
|
@@ -8,6 +8,29 @@
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
@mixin reset-button-styles {
|
|
12
|
+
background: transparent;
|
|
13
|
+
border: none;
|
|
14
|
+
appearance: none;
|
|
15
|
+
margin: 0;
|
|
16
|
+
outline: none;
|
|
17
|
+
padding: 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@mixin reset-link-styles {
|
|
21
|
+
text-decoration: none;
|
|
22
|
+
color: inherit;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
|
|
25
|
+
&:link,
|
|
26
|
+
&:visited,
|
|
27
|
+
&:hover,
|
|
28
|
+
&:active {
|
|
29
|
+
text-decoration: none;
|
|
30
|
+
color: inherit;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
11
34
|
@mixin get-typography($name) {
|
|
12
35
|
font-family: var(--typography-#{$name}-font-family) !important;
|
|
13
36
|
font-size: var(--typography-#{$name}-font-size) !important;
|
|
@@ -58,18 +81,15 @@
|
|
|
58
81
|
}
|
|
59
82
|
}
|
|
60
83
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
border-end-end-radius: var(--#{$name}-container-shape-end-end, var(--#{$name}-container-shape));
|
|
66
|
-
corner-shape: var(--#{$name}-container-shape-variant);
|
|
84
|
+
|
|
85
|
+
// Layers
|
|
86
|
+
@mixin layer-background {
|
|
87
|
+
|
|
67
88
|
}
|
|
68
89
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
90
|
+
// NOTE: `apply-container-shape` and `copy-container-shape` were removed.
|
|
91
|
+
// These helpers previously copied container-shape custom properties and
|
|
92
|
+
// applied them as physical border radii. They are intentionally deleted
|
|
93
|
+
// because the loader now manages container shape via CSS custom properties
|
|
94
|
+
// directly. If you need to reintroduce shape helpers, add small, focused
|
|
95
|
+
// utilities instead of the previous macros.
|
package/scss/styles.scss
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
@use 'tokens.css';
|
|
2
2
|
@use '../src/text/text.css-component.scss';
|
|
3
3
|
@use '../src/link/link.css-component.scss';
|
|
4
|
-
@use '../src/popover/tooltip.css-component.scss';
|
|
5
|
-
|
|
6
4
|
|
|
7
5
|
|
|
8
6
|
|
|
@@ -61,4 +59,4 @@
|
|
|
61
59
|
.scrollbar-primary::-webkit-scrollbar-thumb {
|
|
62
60
|
background-color: var(--color-primary);
|
|
63
61
|
border-radius: calc(var(--scrollbar-width) / 2);
|
|
64
|
-
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { isServer, ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An element that can be attached to an associated controlling element.
|
|
5
|
+
*/
|
|
6
|
+
export interface Attachable {
|
|
7
|
+
/**
|
|
8
|
+
* Reflects the value of the `for` attribute, which is the ID of the element's
|
|
9
|
+
* associated control.
|
|
10
|
+
*
|
|
11
|
+
* Use this when the elements's associated control is not its parent.
|
|
12
|
+
*
|
|
13
|
+
* To manually control an element, set its `for` attribute to `""`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```html
|
|
17
|
+
* <div class="container">
|
|
18
|
+
* <md-attachable for="interactive"></md-attachable>
|
|
19
|
+
* <button id="interactive">Action</button>
|
|
20
|
+
* </div>
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```html
|
|
25
|
+
* <button class="manually-controlled">
|
|
26
|
+
* <md-attachable for=""></md-attachable>
|
|
27
|
+
* </button>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
htmlFor: string | null;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Gets or sets the element that controls the visibility of the attachable
|
|
34
|
+
* element. It is one of:
|
|
35
|
+
*
|
|
36
|
+
* - The control referenced by the `for` attribute.
|
|
37
|
+
* - The control provided to `element.attach(control)`
|
|
38
|
+
* - The element's parent.
|
|
39
|
+
* - `null` if the element is not controlled.
|
|
40
|
+
*/
|
|
41
|
+
control: HTMLElement | null;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Attaches the element to an interactive control.
|
|
45
|
+
*
|
|
46
|
+
* @param control The element that controls the attachable element.
|
|
47
|
+
*/
|
|
48
|
+
attach(control: HTMLElement): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Detaches the element from its current control.
|
|
52
|
+
*/
|
|
53
|
+
detach(): void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A key to retrieve an `Attachable` element's `AttachableController` from a
|
|
58
|
+
* global `MutationObserver`.
|
|
59
|
+
*/
|
|
60
|
+
const ATTACHABLE_CONTROLLER = Symbol('attachableController');
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The host of an `AttachableController`. The controller will add itself to
|
|
64
|
+
* the host so it can be retrieved in a global `MutationObserver`.
|
|
65
|
+
*/
|
|
66
|
+
interface AttachableControllerHost extends ReactiveControllerHost, HTMLElement {
|
|
67
|
+
[ATTACHABLE_CONTROLLER]?: AttachableController;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let FOR_ATTRIBUTE_OBSERVER: MutationObserver | undefined;
|
|
71
|
+
|
|
72
|
+
if (!isServer) {
|
|
73
|
+
/**
|
|
74
|
+
* A global `MutationObserver` that reacts to `for` attribute changes on
|
|
75
|
+
* `Attachable` elements. If the `for` attribute changes, the controller will
|
|
76
|
+
* re-attach to the new referenced element.
|
|
77
|
+
*/
|
|
78
|
+
FOR_ATTRIBUTE_OBSERVER = new MutationObserver(records => {
|
|
79
|
+
for (const record of records) {
|
|
80
|
+
// When a control's `for` attribute changes, inform its
|
|
81
|
+
// `AttachableController` to update to a new control.
|
|
82
|
+
(record.target as AttachableControllerHost)[
|
|
83
|
+
ATTACHABLE_CONTROLLER
|
|
84
|
+
]?.hostConnected();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A controller that provides an implementation for `Attachable` elements.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* class MyElement extends LitElement implements Attachable {
|
|
95
|
+
* get control() { return this.attachableController.control; }
|
|
96
|
+
*
|
|
97
|
+
* private readonly attachableController = new AttachableController(
|
|
98
|
+
* this,
|
|
99
|
+
* (previousControl, newControl) => {
|
|
100
|
+
* previousControl?.removeEventListener('click', this.handleClick);
|
|
101
|
+
* newControl?.addEventListener('click', this.handleClick);
|
|
102
|
+
* }
|
|
103
|
+
* );
|
|
104
|
+
*
|
|
105
|
+
* // Implement remaining `Attachable` properties/methods that call the
|
|
106
|
+
* // controller's properties/methods.
|
|
107
|
+
* }
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export class AttachableController implements ReactiveController, Attachable {
|
|
111
|
+
get htmlFor() {
|
|
112
|
+
return this.host.getAttribute('for');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
set htmlFor(htmlFor: string | null) {
|
|
116
|
+
if (htmlFor === null) {
|
|
117
|
+
this.host.removeAttribute('for');
|
|
118
|
+
} else {
|
|
119
|
+
this.host.setAttribute('for', htmlFor);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
get control() {
|
|
124
|
+
if (this.host.hasAttribute('for')) {
|
|
125
|
+
if (!this.htmlFor || !this.host.isConnected) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
this.host.getRootNode() as Document | ShadowRoot
|
|
131
|
+
).querySelector<HTMLElement>(`#${this.htmlFor}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return this.currentControl || this.host.parentElement;
|
|
135
|
+
}
|
|
136
|
+
set control(control: HTMLElement | null) {
|
|
137
|
+
if (control) {
|
|
138
|
+
this.attach(control);
|
|
139
|
+
} else {
|
|
140
|
+
this.detach();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private currentControl: HTMLElement | null = null;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Creates a new controller for an `Attachable` element.
|
|
148
|
+
*
|
|
149
|
+
* @param host The `Attachable` element.
|
|
150
|
+
* @param onControlChange A callback with two parameters for the previous and
|
|
151
|
+
* next control. An `Attachable` element may perform setup or teardown
|
|
152
|
+
* logic whenever the control changes.
|
|
153
|
+
*/
|
|
154
|
+
constructor(
|
|
155
|
+
private readonly host: AttachableControllerHost,
|
|
156
|
+
private readonly onControlChange: (
|
|
157
|
+
prev: HTMLElement | null,
|
|
158
|
+
next: HTMLElement | null,
|
|
159
|
+
) => void,
|
|
160
|
+
) {
|
|
161
|
+
host.addController(this);
|
|
162
|
+
host[ATTACHABLE_CONTROLLER] = this;
|
|
163
|
+
FOR_ATTRIBUTE_OBSERVER?.observe(host, { attributeFilter: ['for'] });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
attach(control: HTMLElement) {
|
|
167
|
+
if (control === this.currentControl) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.setCurrentControl(control);
|
|
172
|
+
// When imperatively attaching, remove the `for` attribute so
|
|
173
|
+
// that the attached control is used instead of a referenced one.
|
|
174
|
+
this.host.removeAttribute('for');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
detach() {
|
|
178
|
+
this.setCurrentControl(null);
|
|
179
|
+
// When imperatively detaching, add an empty `for=""` attribute. This will
|
|
180
|
+
// ensure the control is `null` rather than the `parentElement`.
|
|
181
|
+
this.host.setAttribute('for', '');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** @private */
|
|
185
|
+
hostConnected() {
|
|
186
|
+
this.setCurrentControl(this.control);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** @private */
|
|
190
|
+
hostDisconnected() {
|
|
191
|
+
this.setCurrentControl(null);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private setCurrentControl(control: HTMLElement | null) {
|
|
195
|
+
this.onControlChange(this.currentControl, control);
|
|
196
|
+
this.currentControl = control;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import type { MixinConstructor } from './MixinConstructor.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 1. Define an interface for the members the mixin adds.
|
|
7
|
+
* This makes the type annotation much cleaner.
|
|
8
|
+
*/
|
|
9
|
+
export interface NativeButtonInterface {
|
|
10
|
+
htmlType: 'button' | 'submit' | 'reset';
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
softDisabled: boolean;
|
|
13
|
+
disabledReason: string;
|
|
14
|
+
form: string;
|
|
15
|
+
name: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 2. Apply the type annotation to the variable.
|
|
21
|
+
*/
|
|
22
|
+
const NativeButtonMixin: <T extends MixinConstructor<LitElement>>(
|
|
23
|
+
superclass: T,
|
|
24
|
+
) => T & MixinConstructor<NativeButtonInterface> = <
|
|
25
|
+
T extends MixinConstructor<LitElement>,
|
|
26
|
+
>(
|
|
27
|
+
superclass: T,
|
|
28
|
+
) => {
|
|
29
|
+
// Naming the class (BaseButtonElement) instead of using 'Mixin' or anonymous
|
|
30
|
+
// prevents the "__childPart" visibility error.
|
|
31
|
+
class ButtonElement extends superclass implements NativeButtonInterface {
|
|
32
|
+
/**
|
|
33
|
+
* The type of the underlying `<button>` element. Maps to the native `type` attribute.
|
|
34
|
+
* Possible values are `"button"`, `"submit"`, `"reset"`. Defaults to `"button"`.
|
|
35
|
+
*/
|
|
36
|
+
@property({ type: String }) htmlType: 'button' | 'submit' | 'reset' =
|
|
37
|
+
'button';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* When `true`, the button is disabled and cannot be interacted with. Reflects to the `disabled` attribute. Defaults to `false`.
|
|
41
|
+
*/
|
|
42
|
+
@property({ type: Boolean, reflect: true })
|
|
43
|
+
disabled: boolean = false;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* When `true`, the button is visually styled as disabled and cannot be interacted with, but remains focusable.
|
|
47
|
+
* Use this in combination with `disabledReason` to communicate why the button is unavailable.
|
|
48
|
+
* Reflects to the `soft-disabled` attribute. Defaults to `false`.
|
|
49
|
+
*/
|
|
50
|
+
@property({ type: Boolean, reflect: true, attribute: 'soft-disabled' })
|
|
51
|
+
softDisabled: boolean = false;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A human-readable explanation of why the button is disabled or soft-disabled.
|
|
55
|
+
* Rendered as a visually hidden tooltip and linked via `aria-describedby` for accessibility.
|
|
56
|
+
* Maps to the `disabled-reason` attribute.
|
|
57
|
+
*/
|
|
58
|
+
@property({ attribute: 'disabled-reason' })
|
|
59
|
+
disabledReason: string = '';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The `id` of the `<form>` element to associate the button with.
|
|
63
|
+
* If omitted, the button is associated with its nearest ancestor form.
|
|
64
|
+
* Maps to the native `form` attribute.
|
|
65
|
+
*/
|
|
66
|
+
@property()
|
|
67
|
+
form: string = '';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The name of the button, submitted as part of a name/value pair when the associated form is submitted.
|
|
71
|
+
* Maps to the native `name` attribute.
|
|
72
|
+
*/
|
|
73
|
+
@property()
|
|
74
|
+
name: string = '';
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The value of the button, submitted as part of a name/value pair when the associated form is submitted.
|
|
78
|
+
* Maps to the native `value` attribute.
|
|
79
|
+
*/
|
|
80
|
+
@property()
|
|
81
|
+
value: string = '';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return ButtonElement as T & MixinConstructor<NativeButtonInterface>;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default NativeButtonMixin;
|
|
@@ -2,26 +2,33 @@ import { LitElement } from 'lit';
|
|
|
2
2
|
import { property } from 'lit/decorators.js';
|
|
3
3
|
import type { MixinConstructor } from './MixinConstructor.js';
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* 1. Define an interface for the members the mixin adds.
|
|
8
7
|
* This makes the type annotation much cleaner.
|
|
9
8
|
*/
|
|
10
|
-
export interface
|
|
9
|
+
export interface NativeHyperlinkInterface {
|
|
11
10
|
href?: string;
|
|
12
11
|
target: '_self' | '_parent' | '_blank' | '_top' | string;
|
|
13
12
|
rel?: string;
|
|
14
13
|
download?: string;
|
|
15
|
-
__isLink(): boolean;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
/**
|
|
19
17
|
* 2. Apply the type annotation to the variable.
|
|
20
18
|
*/
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
const NativeHyperlinkMixin: <T extends MixinConstructor<LitElement>>(
|
|
20
|
+
superclass: T,
|
|
21
|
+
) => T & MixinConstructor<NativeHyperlinkInterface> = <
|
|
22
|
+
T extends MixinConstructor<LitElement>,
|
|
23
|
+
>(
|
|
24
|
+
superclass: T,
|
|
25
|
+
) => {
|
|
26
|
+
// Naming the class (BaseHyperlinkElement) instead of using 'Mixin' or anonymous
|
|
23
27
|
// prevents the "__childPart" visibility error.
|
|
24
|
-
class BaseHyperlinkElement
|
|
28
|
+
class BaseHyperlinkElement
|
|
29
|
+
extends superclass
|
|
30
|
+
implements NativeHyperlinkInterface
|
|
31
|
+
{
|
|
25
32
|
/**
|
|
26
33
|
* The URL that the hyperlink points to. When set, the component renders as an `<a>` element.
|
|
27
34
|
* Maps to the native `href` attribute.
|
|
@@ -53,16 +60,9 @@ const BaseHyperlinkMixin: <T extends MixinConstructor<LitElement>>(superclass: T
|
|
|
53
60
|
*/
|
|
54
61
|
@property()
|
|
55
62
|
download?: string;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Returns `true` when `href` is set, indicating the component should render as a link.
|
|
59
|
-
*/
|
|
60
|
-
__isLink(): boolean {
|
|
61
|
-
return !!this.href;
|
|
62
|
-
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
return BaseHyperlinkElement as T & MixinConstructor<
|
|
65
|
+
return BaseHyperlinkElement as T & MixinConstructor<NativeHyperlinkInterface>;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
export default
|
|
68
|
+
export default NativeHyperlinkMixin;
|
|
@@ -20,19 +20,51 @@ export function observerSlotChangesWithCallback(
|
|
|
20
20
|
slot: HTMLSlotElement | null,
|
|
21
21
|
callback: (hasContent: boolean) => void,
|
|
22
22
|
) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
if (!slot) return () => {};
|
|
24
|
+
|
|
25
|
+
// Keep track of observers for current assigned nodes so we can reconnect
|
|
26
|
+
let observers: MutationObserver[] = [];
|
|
27
|
+
|
|
28
|
+
const observeAssignedNodes = () => {
|
|
29
|
+
// disconnect previous observers
|
|
30
|
+
observers.forEach(o => o.disconnect());
|
|
31
|
+
observers = [];
|
|
32
|
+
|
|
33
|
+
const assigned = slot.assignedNodes({ flatten: true }) || [];
|
|
34
|
+
assigned.forEach(node => {
|
|
35
|
+
const obs = new MutationObserver(() => {
|
|
36
|
+
callback(hasMeaningfulContent(slot));
|
|
37
|
+
});
|
|
38
|
+
try {
|
|
39
|
+
obs.observe(node as Node, {
|
|
40
|
+
attributes: true,
|
|
41
|
+
childList: true,
|
|
42
|
+
characterData: true,
|
|
43
|
+
subtree: true,
|
|
44
|
+
});
|
|
45
|
+
observers.push(obs);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
// ignore nodes that cannot be observed
|
|
48
|
+
}
|
|
34
49
|
});
|
|
35
|
-
});
|
|
36
50
|
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
// initial check
|
|
52
|
+
callback(hasMeaningfulContent(slot));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// When assigned nodes change (elements added/removed), the slot emits a slotchange
|
|
56
|
+
// event — re-run observer setup so we track the new nodes. This fixes the case
|
|
57
|
+
// where an element (e.g. <wc-icon>) is removed from light DOM: previously we
|
|
58
|
+
// only observed the old node and wouldn't detect its removal.
|
|
59
|
+
const onSlotChange = () => observeAssignedNodes();
|
|
60
|
+
slot.addEventListener('slotchange', onSlotChange);
|
|
61
|
+
|
|
62
|
+
// Start observing
|
|
63
|
+
observeAssignedNodes();
|
|
64
|
+
|
|
65
|
+
// Return a cleanup function so callers can disconnect observers when needed.
|
|
66
|
+
return () => {
|
|
67
|
+
observers.forEach(o => o.disconnect());
|
|
68
|
+
slot.removeEventListener('slotchange', onSlotChange);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -8,7 +8,6 @@ import styles from './accordion-item.scss';
|
|
|
8
8
|
* @tag wc-accordion-item
|
|
9
9
|
* @rawTag accordion-item
|
|
10
10
|
* @summary An expansion panel with a header that reveals or hides associated content. Follows Material Design 3 expansion panel guidelines.
|
|
11
|
-
* @parentRawTag accordion
|
|
12
11
|
*
|
|
13
12
|
* @slot - The body content revealed when the panel is expanded.
|
|
14
13
|
* @slot heading - The panel title. Renders as `body-large` text.
|
|
@@ -8,7 +8,6 @@ import styles from './breadcrumb-item.scss';
|
|
|
8
8
|
* @label Breadcrumb Item
|
|
9
9
|
* @tag wc-breadcrumb-item
|
|
10
10
|
* @rawTag breadcrumb-item
|
|
11
|
-
* @parentRawTag breadcrumb
|
|
12
11
|
* @summary A breadcrumb item component that represents a single item in a breadcrumb navigation.
|
|
13
12
|
* @tags navigation
|
|
14
13
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DISABLED_REASON_ID = 'button-disabled-reason';
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
|
|
21
21
|
@mixin _button-color-toggle-unselected($color) {
|
|
22
22
|
|
|
23
|
-
--filled-button-container-color: var(--color-surface-container);
|
|
24
|
-
--filled-button-label-text-color: var(--color-surface
|
|
23
|
+
--filled-button-container-color: var(--color-surface-container-high);
|
|
24
|
+
--filled-button-label-text-color: var(--color-on-surface);
|
|
25
25
|
|
|
26
26
|
--tonal-button-container-color: var(--color-#{$color}-container);
|
|
27
27
|
--tonal-button-label-text-color: var(--color-on-#{$color}-container);
|