@webtides/element-library 0.1.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/CHANGELOG.md +109 -0
- package/LICENSE +21 -0
- package/README.md +125 -0
- package/all.js +26 -0
- package/custom-elements.json +7683 -0
- package/index.js +3 -0
- package/package.json +132 -0
- package/patches/@glidejs+glide+3.6.2.patch +11 -0
- package/src/components/accordion/accordion.changelog.md +47 -0
- package/src/components/accordion/accordion.define.js +3 -0
- package/src/components/accordion/accordion.events.js +3 -0
- package/src/components/accordion/accordion.js +144 -0
- package/src/components/accordion/accordion.readme.md +71 -0
- package/src/components/accordion/accordion.style.js +64 -0
- package/src/components/accordion-group/accordion-group.changelog.md +35 -0
- package/src/components/accordion-group/accordion-group.define.js +3 -0
- package/src/components/accordion-group/accordion-group.js +63 -0
- package/src/components/accordion-group/accordion-group.readme.md +56 -0
- package/src/components/amount-field/amount-field.changelog.md +40 -0
- package/src/components/amount-field/amount-field.define.js +3 -0
- package/src/components/amount-field/amount-field.js +91 -0
- package/src/components/amount-field/amount-field.readme.md +65 -0
- package/src/components/amount-field/amount-field.style.js +58 -0
- package/src/components/button/button.changelog.md +19 -0
- package/src/components/button/button.define.js +3 -0
- package/src/components/button/button.js +174 -0
- package/src/components/button/button.readme.md +91 -0
- package/src/components/button/button.style.js +251 -0
- package/src/components/carousel/carousel.changelog.md +58 -0
- package/src/components/carousel/carousel.define.js +3 -0
- package/src/components/carousel/carousel.events.js +3 -0
- package/src/components/carousel/carousel.js +232 -0
- package/src/components/carousel/carousel.readme.md +78 -0
- package/src/components/carousel/carousel.style.js +142 -0
- package/src/components/carousel/glide/components/ShadowAnchors.js +12 -0
- package/src/components/carousel/glide/components/ShadowClones.js +41 -0
- package/src/components/carousel/glide/components/ShadowGaps.js +28 -0
- package/src/components/carousel/glide/components/ShadowHtml.js +32 -0
- package/src/components/checkbox-field/checkbox-field.changelog.md +47 -0
- package/src/components/checkbox-field/checkbox-field.define.js +3 -0
- package/src/components/checkbox-field/checkbox-field.js +102 -0
- package/src/components/checkbox-field/checkbox-field.readme.md +66 -0
- package/src/components/checkbox-field/checkbox-field.style.js +69 -0
- package/src/components/dialog/dialog.changelog.md +24 -0
- package/src/components/dialog/dialog.define.js +3 -0
- package/src/components/dialog/dialog.events.js +8 -0
- package/src/components/dialog/dialog.js +271 -0
- package/src/components/dialog/dialog.readme.md +122 -0
- package/src/components/dialog/dialog.style.js +124 -0
- package/src/components/dropdown/dropdown.changelog.md +39 -0
- package/src/components/dropdown/dropdown.define.js +3 -0
- package/src/components/dropdown/dropdown.js +98 -0
- package/src/components/dropdown/dropdown.readme.md +69 -0
- package/src/components/dropdown/dropdown.style.js +17 -0
- package/src/components/form-field/form-field.changelog.md +35 -0
- package/src/components/form-field/form-field.define.js +3 -0
- package/src/components/form-field/form-field.events.js +4 -0
- package/src/components/form-field/form-field.js +210 -0
- package/src/components/form-field/form-field.readme.md +80 -0
- package/src/components/form-field/form-field.style.js +25 -0
- package/src/components/input-field/input-field.changelog.md +39 -0
- package/src/components/input-field/input-field.define.js +3 -0
- package/src/components/input-field/input-field.js +71 -0
- package/src/components/input-field/input-field.readme.md +90 -0
- package/src/components/input-field/input-field.style.js +33 -0
- package/src/components/lazy-src/lazy-src.changelog.md +57 -0
- package/src/components/lazy-src/lazy-src.define.js +3 -0
- package/src/components/lazy-src/lazy-src.events.js +5 -0
- package/src/components/lazy-src/lazy-src.js +100 -0
- package/src/components/lazy-src/lazy-src.readme.md +63 -0
- package/src/components/notification/notification.changelog.md +22 -0
- package/src/components/notification/notification.define.js +3 -0
- package/src/components/notification/notification.events.js +6 -0
- package/src/components/notification/notification.js +280 -0
- package/src/components/notification/notification.readme.md +98 -0
- package/src/components/notification/notification.style.js +113 -0
- package/src/components/password-field/password-field.changelog.md +22 -0
- package/src/components/password-field/password-field.define.js +3 -0
- package/src/components/password-field/password-field.js +113 -0
- package/src/components/password-field/password-field.readme.md +60 -0
- package/src/components/password-field/password-field.style.js +62 -0
- package/src/components/radio-field/radio-field.changelog.md +21 -0
- package/src/components/radio-field/radio-field.define.js +3 -0
- package/src/components/radio-field/radio-field.js +140 -0
- package/src/components/radio-field/radio-field.readme.md +72 -0
- package/src/components/radio-field/radio-field.style.js +108 -0
- package/src/components/scroll-to/scroll-to.changelog.md +39 -0
- package/src/components/scroll-to/scroll-to.define.js +3 -0
- package/src/components/scroll-to/scroll-to.js +40 -0
- package/src/components/scroll-to/scroll-to.readme.md +50 -0
- package/src/components/scroll-to-top/scroll-to-top.changelog.md +39 -0
- package/src/components/scroll-to-top/scroll-to-top.define.js +3 -0
- package/src/components/scroll-to-top/scroll-to-top.js +78 -0
- package/src/components/scroll-to-top/scroll-to-top.readme.md +48 -0
- package/src/components/scroll-to-top/scroll-to-top.style.js +9 -0
- package/src/components/select-field/select-field.changelog.md +30 -0
- package/src/components/select-field/select-field.define.js +3 -0
- package/src/components/select-field/select-field.js +83 -0
- package/src/components/select-field/select-field.readme.md +131 -0
- package/src/components/select-field/select-field.style.js +24 -0
- package/src/components/slider/slider.changelog.md +177 -0
- package/src/components/slider/slider.define.js +3 -0
- package/src/components/slider/slider.events.js +4 -0
- package/src/components/slider/slider.js +338 -0
- package/src/components/slider/slider.readme.md +87 -0
- package/src/components/slider/slider.style.js +107 -0
- package/src/components/sticky/sticky.changelog.md +43 -0
- package/src/components/sticky/sticky.define.js +3 -0
- package/src/components/sticky/sticky.js +105 -0
- package/src/components/sticky/sticky.readme.md +63 -0
- package/src/components/sticky/sticky.style.js +21 -0
- package/src/components/svg-use/svg-use.changelog.md +41 -0
- package/src/components/svg-use/svg-use.define.js +3 -0
- package/src/components/svg-use/svg-use.js +39 -0
- package/src/components/svg-use/svg-use.readme.md +50 -0
- package/src/components/svg-use/svg-use.style.js +20 -0
- package/src/components/switch-field/switch-field.changelog.md +21 -0
- package/src/components/switch-field/switch-field.define.js +3 -0
- package/src/components/switch-field/switch-field.js +99 -0
- package/src/components/switch-field/switch-field.readme.md +58 -0
- package/src/components/switch-field/switch-field.style.js +98 -0
- package/src/components/tab-group/tab-group.changelog.md +35 -0
- package/src/components/tab-group/tab-group.define.js +3 -0
- package/src/components/tab-group/tab-group.js +109 -0
- package/src/components/tab-group/tab-group.readme.md +61 -0
- package/src/components/tab-group/tab-group.style.js +7 -0
- package/src/components/tab-link/tab-link.changelog.md +35 -0
- package/src/components/tab-link/tab-link.define.js +3 -0
- package/src/components/tab-link/tab-link.js +50 -0
- package/src/components/tab-link/tab-link.readme.md +66 -0
- package/src/components/tab-link/tab-link.style.js +32 -0
- package/src/components/tab-panel/tab-panel.changelog.md +39 -0
- package/src/components/tab-panel/tab-panel.define.js +3 -0
- package/src/components/tab-panel/tab-panel.js +30 -0
- package/src/components/tab-panel/tab-panel.readme.md +57 -0
- package/src/components/tab-panel/tab-panel.style.js +7 -0
- package/src/components/textarea-field/textarea-field.changelog.md +39 -0
- package/src/components/textarea-field/textarea-field.define.js +3 -0
- package/src/components/textarea-field/textarea-field.js +62 -0
- package/src/components/textarea-field/textarea-field.readme.md +102 -0
- package/src/components/textarea-field/textarea-field.style.js +7 -0
- package/src/components/transition-classes/transition-classes.changelog.md +39 -0
- package/src/components/transition-classes/transition-classes.define.js +3 -0
- package/src/components/transition-classes/transition-classes.js +154 -0
- package/src/components/transition-classes/transition-classes.readme.md +71 -0
- package/src/themes/default.css +165 -0
- package/src/themes/high-contrast.css +147 -0
- package/src/themes/sketchy.css +238 -0
- package/types/all.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/src/components/accordion/accordion.d.ts +60 -0
- package/types/src/components/accordion/accordion.define.d.ts +1 -0
- package/types/src/components/accordion/accordion.events.d.ts +4 -0
- package/types/src/components/accordion/accordion.style.d.ts +2 -0
- package/types/src/components/accordion-group/accordion-group.d.ts +28 -0
- package/types/src/components/accordion-group/accordion-group.define.d.ts +1 -0
- package/types/src/components/amount-field/amount-field.d.ts +53 -0
- package/types/src/components/amount-field/amount-field.define.d.ts +1 -0
- package/types/src/components/amount-field/amount-field.style.d.ts +2 -0
- package/types/src/components/button/button.d.ts +73 -0
- package/types/src/components/button/button.define.d.ts +1 -0
- package/types/src/components/button/button.style.d.ts +2 -0
- package/types/src/components/carousel/carousel.d.ts +79 -0
- package/types/src/components/carousel/carousel.define.d.ts +1 -0
- package/types/src/components/carousel/carousel.events.d.ts +4 -0
- package/types/src/components/carousel/carousel.style.d.ts +2 -0
- package/types/src/components/carousel/glide/components/ShadowAnchors.d.ts +1 -0
- package/types/src/components/carousel/glide/components/ShadowClones.d.ts +1 -0
- package/types/src/components/carousel/glide/components/ShadowGaps.d.ts +1 -0
- package/types/src/components/carousel/glide/components/ShadowHtml.d.ts +1 -0
- package/types/src/components/checkbox-field/checkbox-field.d.ts +69 -0
- package/types/src/components/checkbox-field/checkbox-field.define.d.ts +1 -0
- package/types/src/components/checkbox-field/checkbox-field.style.d.ts +2 -0
- package/types/src/components/dialog/dialog.d.ts +103 -0
- package/types/src/components/dialog/dialog.define.d.ts +1 -0
- package/types/src/components/dialog/dialog.events.d.ts +9 -0
- package/types/src/components/dialog/dialog.style.d.ts +2 -0
- package/types/src/components/dropdown/dropdown.d.ts +45 -0
- package/types/src/components/dropdown/dropdown.define.d.ts +1 -0
- package/types/src/components/dropdown/dropdown.style.d.ts +2 -0
- package/types/src/components/form-field/form-field.d.ts +110 -0
- package/types/src/components/form-field/form-field.define.d.ts +1 -0
- package/types/src/components/form-field/form-field.events.d.ts +5 -0
- package/types/src/components/form-field/form-field.style.d.ts +2 -0
- package/types/src/components/input-field/input-field.d.ts +38 -0
- package/types/src/components/input-field/input-field.define.d.ts +1 -0
- package/types/src/components/input-field/input-field.style.d.ts +2 -0
- package/types/src/components/lazy-src/lazy-src.d.ts +46 -0
- package/types/src/components/lazy-src/lazy-src.define.d.ts +1 -0
- package/types/src/components/lazy-src/lazy-src.events.d.ts +6 -0
- package/types/src/components/notification/notification.d.ts +92 -0
- package/types/src/components/notification/notification.define.d.ts +1 -0
- package/types/src/components/notification/notification.events.d.ts +7 -0
- package/types/src/components/notification/notification.style.d.ts +2 -0
- package/types/src/components/password-field/password-field.d.ts +66 -0
- package/types/src/components/password-field/password-field.define.d.ts +1 -0
- package/types/src/components/password-field/password-field.style.d.ts +2 -0
- package/types/src/components/radio-field/radio-field.d.ts +62 -0
- package/types/src/components/radio-field/radio-field.define.d.ts +1 -0
- package/types/src/components/radio-field/radio-field.style.d.ts +2 -0
- package/types/src/components/scroll-to/scroll-to.d.ts +24 -0
- package/types/src/components/scroll-to/scroll-to.define.d.ts +1 -0
- package/types/src/components/scroll-to-top/scroll-to-top.d.ts +32 -0
- package/types/src/components/scroll-to-top/scroll-to-top.define.d.ts +1 -0
- package/types/src/components/scroll-to-top/scroll-to-top.style.d.ts +2 -0
- package/types/src/components/select-field/select-field.d.ts +39 -0
- package/types/src/components/select-field/select-field.define.d.ts +1 -0
- package/types/src/components/select-field/select-field.style.d.ts +2 -0
- package/types/src/components/slider/slider.d.ts +129 -0
- package/types/src/components/slider/slider.define.d.ts +1 -0
- package/types/src/components/slider/slider.events.d.ts +5 -0
- package/types/src/components/slider/slider.style.d.ts +2 -0
- package/types/src/components/sticky/sticky.d.ts +47 -0
- package/types/src/components/sticky/sticky.define.d.ts +1 -0
- package/types/src/components/sticky/sticky.style.d.ts +2 -0
- package/types/src/components/svg-use/svg-use.d.ts +18 -0
- package/types/src/components/svg-use/svg-use.define.d.ts +1 -0
- package/types/src/components/svg-use/svg-use.style.d.ts +2 -0
- package/types/src/components/switch-field/switch-field.d.ts +67 -0
- package/types/src/components/switch-field/switch-field.define.d.ts +1 -0
- package/types/src/components/switch-field/switch-field.style.d.ts +2 -0
- package/types/src/components/tab-group/tab-group.d.ts +48 -0
- package/types/src/components/tab-group/tab-group.define.d.ts +1 -0
- package/types/src/components/tab-group/tab-group.style.d.ts +2 -0
- package/types/src/components/tab-link/tab-link.d.ts +30 -0
- package/types/src/components/tab-link/tab-link.define.d.ts +1 -0
- package/types/src/components/tab-link/tab-link.style.d.ts +2 -0
- package/types/src/components/tab-panel/tab-panel.d.ts +18 -0
- package/types/src/components/tab-panel/tab-panel.define.d.ts +1 -0
- package/types/src/components/tab-panel/tab-panel.style.d.ts +2 -0
- package/types/src/components/textarea-field/textarea-field.d.ts +34 -0
- package/types/src/components/textarea-field/textarea-field.define.d.ts +1 -0
- package/types/src/components/textarea-field/textarea-field.style.d.ts +2 -0
- package/types/src/components/transition-classes/transition-classes.d.ts +52 -0
- package/types/src/components/transition-classes/transition-classes.define.d.ts +1 -0
- package/types/src/utils/body-scroll.d.ts +4 -0
- package/types/src/utils/transitions.d.ts +9 -0
- package/web-types.json +3956 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
const css = String.raw;
|
|
2
|
+
|
|
3
|
+
export default css`
|
|
4
|
+
:host {
|
|
5
|
+
display: block;
|
|
6
|
+
pointer-events: auto;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* The animated wrapper. Visibility is managed imperatively (is-hidden / showing classes) rather
|
|
11
|
+
* than via the reflected [open] attribute, so the exit transition can play before the element is
|
|
12
|
+
* fully hidden. The class is intentionally not bound in the template (which would wipe these).
|
|
13
|
+
*/
|
|
14
|
+
[part~='base'] {
|
|
15
|
+
opacity: 0;
|
|
16
|
+
transform: translateX(0.75rem);
|
|
17
|
+
transition:
|
|
18
|
+
opacity var(--el-duration-md, 0s) var(--el-ease, ease),
|
|
19
|
+
transform var(--el-duration-md, 0s) var(--el-ease, ease);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[part~='base'].showing {
|
|
23
|
+
opacity: 1;
|
|
24
|
+
transform: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[part~='base'].is-hidden {
|
|
28
|
+
display: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.panel {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
gap: var(--el-space-3, 0.75rem);
|
|
35
|
+
padding: var(--el-space-3, 0.75rem) var(--el-space-4, 1rem);
|
|
36
|
+
/* System colors as the headless fallback: a floating surface needs to be readable over the
|
|
37
|
+
page, so transparent isn't an option here (unlike inline components). */
|
|
38
|
+
background: var(--el-color-bg, Canvas);
|
|
39
|
+
color: var(--el-color-fg, CanvasText);
|
|
40
|
+
border: var(--el-border-width, 1px) solid var(--el-color-border, currentColor);
|
|
41
|
+
border-inline-start: 4px solid var(--variant-color, var(--el-color-border, currentColor));
|
|
42
|
+
border-radius: var(--el-radius-md, 0);
|
|
43
|
+
box-shadow: var(--el-shadow-lg, none);
|
|
44
|
+
min-width: 18rem;
|
|
45
|
+
max-width: 28rem;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.notification--default {
|
|
49
|
+
--variant-color: var(--el-color-border, currentColor);
|
|
50
|
+
}
|
|
51
|
+
.notification--primary {
|
|
52
|
+
--variant-color: var(--el-color-accent, currentColor);
|
|
53
|
+
}
|
|
54
|
+
.notification--success {
|
|
55
|
+
--variant-color: var(--el-color-success, currentColor);
|
|
56
|
+
}
|
|
57
|
+
.notification--neutral {
|
|
58
|
+
--variant-color: var(--el-color-fg-muted, currentColor);
|
|
59
|
+
}
|
|
60
|
+
.notification--warning {
|
|
61
|
+
--variant-color: var(--el-color-warning, #f59e0b);
|
|
62
|
+
}
|
|
63
|
+
.notification--danger {
|
|
64
|
+
--variant-color: var(--el-color-danger, currentColor);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[part~='icon'] {
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
flex: none;
|
|
70
|
+
color: var(--variant-color, currentColor);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
[part~='icon'] svg {
|
|
74
|
+
width: 1.25rem;
|
|
75
|
+
height: 1.25rem;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[part~='message'] {
|
|
79
|
+
flex: 1 1 auto;
|
|
80
|
+
min-width: 0;
|
|
81
|
+
line-height: var(--el-line-height, 1.5);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.close-button {
|
|
85
|
+
flex: none;
|
|
86
|
+
display: inline-flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
padding: 0;
|
|
90
|
+
border: none;
|
|
91
|
+
border-radius: var(--el-radius-sm, 0);
|
|
92
|
+
background: transparent;
|
|
93
|
+
color: var(--el-color-fg-muted, inherit);
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
line-height: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.close-button:focus-visible {
|
|
99
|
+
outline: var(--el-focus-ring-width, 2px) solid var(--el-color-accent, currentColor);
|
|
100
|
+
outline-offset: 2px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.close-button svg {
|
|
104
|
+
width: 1.1rem;
|
|
105
|
+
height: 1.1rem;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@media (prefers-reduced-motion: reduce) {
|
|
109
|
+
[part~='base'] {
|
|
110
|
+
transition-duration: 0s;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
6
|
+
|
|
7
|
+
<!--
|
|
8
|
+
When your PR touches this component, add an entry under Unreleased and
|
|
9
|
+
mirror it (prefixed with the component name) in root CHANGELOG.md.
|
|
10
|
+
Uncomment headings as needed.
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
## Unreleased
|
|
14
|
+
|
|
15
|
+
## [0.1.0] - 2026-06-03
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Initial release of `el-password-field` — a masked password input extending `InputField`. Pins the input `type` to `password` (flipping to `text` while revealed) and adds an optional show/hide reveal button.
|
|
20
|
+
- `passwordToggle` property (default `true`) to show/hide the reveal button, `passwordVisible` state, and a `togglePasswordVisibility()` method.
|
|
21
|
+
- Inherits the label / help / error / validation surface, the `input-change` event and the `touched` / `valid` / `invalid` states from `InputField` / `FormField`.
|
|
22
|
+
- All three shipped themes decorate `el-password-field`'s native input identically to `el-input-field` (border, padding, focus ring, invalid state), so themed password and text fields match.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { html, defineElement } from '@webtides/element-js';
|
|
2
|
+
import InputField from '../input-field/input-field.js';
|
|
3
|
+
import style from './password-field.style.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A password input with an optional show/hide reveal toggle. Extends `InputField` (and therefore
|
|
7
|
+
* `FormField`), inheriting the label / help / error / validation surface; it pins the input `type`
|
|
8
|
+
* to `password` and flips it to `text` while revealed.
|
|
9
|
+
*
|
|
10
|
+
* @element el-password-field
|
|
11
|
+
*
|
|
12
|
+
* @fires {CustomEvent<string>} input-change - Fired when the input's value changes. `detail` is
|
|
13
|
+
* the new value. Bubbles.
|
|
14
|
+
*
|
|
15
|
+
* @property {boolean} passwordToggle - Whether to render the show/hide reveal button. Default `true`.
|
|
16
|
+
* @property {boolean} passwordVisible - Whether the value is currently revealed as plain text.
|
|
17
|
+
* Default `false`.
|
|
18
|
+
*/
|
|
19
|
+
export default class PasswordField extends InputField {
|
|
20
|
+
constructor(options) {
|
|
21
|
+
super({ shadowRender: false, styles: [style], ...options });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
properties() {
|
|
25
|
+
return {
|
|
26
|
+
...super.properties(),
|
|
27
|
+
type: 'password',
|
|
28
|
+
passwordToggle: true,
|
|
29
|
+
passwordVisible: false,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Toggles between masked (`password`) and revealed (`text`) input.
|
|
35
|
+
* @returns {void}
|
|
36
|
+
*/
|
|
37
|
+
togglePasswordVisibility() {
|
|
38
|
+
this.passwordVisible = !this.passwordVisible;
|
|
39
|
+
this.type = this.passwordVisible ? 'text' : 'password';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
events() {
|
|
43
|
+
return {
|
|
44
|
+
...super.events(),
|
|
45
|
+
'[data-password-toggle]': {
|
|
46
|
+
click: () => this.togglePasswordVisibility(),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** @private */
|
|
52
|
+
fieldTemplate() {
|
|
53
|
+
return html` ${super.fieldTemplate()} ${this.passwordToggle ? this.toggleTemplate() : ''} `;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** @private */
|
|
57
|
+
toggleTemplate() {
|
|
58
|
+
return html`
|
|
59
|
+
<button
|
|
60
|
+
type="button"
|
|
61
|
+
class="password-toggle"
|
|
62
|
+
data-password-toggle
|
|
63
|
+
aria-label="${this.passwordVisible ? 'Hide password' : 'Show password'}"
|
|
64
|
+
aria-pressed="${this.passwordVisible ? 'true' : 'false'}"
|
|
65
|
+
?disabled="${this.disabled}"
|
|
66
|
+
>
|
|
67
|
+
${this.passwordVisible ? this.eyeOffIconTemplate() : this.eyeIconTemplate()}
|
|
68
|
+
</button>
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** @private */
|
|
73
|
+
eyeIconTemplate() {
|
|
74
|
+
return html`
|
|
75
|
+
<svg
|
|
76
|
+
viewBox="0 0 24 24"
|
|
77
|
+
fill="none"
|
|
78
|
+
stroke="currentColor"
|
|
79
|
+
stroke-width="2"
|
|
80
|
+
stroke-linecap="round"
|
|
81
|
+
stroke-linejoin="round"
|
|
82
|
+
aria-hidden="true"
|
|
83
|
+
>
|
|
84
|
+
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
|
|
85
|
+
<circle cx="12" cy="12" r="3"></circle>
|
|
86
|
+
</svg>
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** @private */
|
|
91
|
+
eyeOffIconTemplate() {
|
|
92
|
+
return html`
|
|
93
|
+
<svg
|
|
94
|
+
viewBox="0 0 24 24"
|
|
95
|
+
fill="none"
|
|
96
|
+
stroke="currentColor"
|
|
97
|
+
stroke-width="2"
|
|
98
|
+
stroke-linecap="round"
|
|
99
|
+
stroke-linejoin="round"
|
|
100
|
+
aria-hidden="true"
|
|
101
|
+
>
|
|
102
|
+
<path
|
|
103
|
+
d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"
|
|
104
|
+
></path>
|
|
105
|
+
<line x1="1" y1="1" x2="23" y2="23"></line>
|
|
106
|
+
</svg>
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function define() {
|
|
112
|
+
defineElement('el-password-field', PasswordField);
|
|
113
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# PasswordField
|
|
2
|
+
|
|
3
|
+
`password-field` is a masked password input with an optional show/hide reveal toggle. It extends `input-field` (and therefore `form-field`), inheriting the label, help text, error message, `required` and validation surface; it pins the input `type` to `password` and flips it to `text` while revealed.
|
|
4
|
+
|
|
5
|
+
It is headless by default, like `input-field` — the native input keeps its browser look until a theme decorates it.
|
|
6
|
+
|
|
7
|
+
## How to use
|
|
8
|
+
|
|
9
|
+
#### Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm i --save @webtides/element-library
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
#### Use
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import '@webtides/element-library/password-field/define';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<el-password-field name="password" label="Password" required="true"></el-password-field>
|
|
23
|
+
|
|
24
|
+
<!-- Hide the reveal button -->
|
|
25
|
+
<el-password-field name="pin" label="PIN" password-toggle="false"></el-password-field>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API
|
|
29
|
+
|
|
30
|
+
#### Properties/Attributes
|
|
31
|
+
|
|
32
|
+
Inherits all of `input-field`'s properties (`name`, `value`, `placeholder`, `required`, `disabled`, `label`, `labelScreenReaderOnly`, `errorMessage`, `helpMessage`, `pattern`, `valid`, `touched`) and adds:
|
|
33
|
+
|
|
34
|
+
| Name | Type | Default | Description |
|
|
35
|
+
| ------------------ | --------- | ------- | ------------------------------------------------------ |
|
|
36
|
+
| `password-toggle` | `boolean` | `true` | Whether to render the show/hide reveal button. |
|
|
37
|
+
| `password-visible` | `boolean` | `false` | Whether the value is currently revealed as plain text. |
|
|
38
|
+
|
|
39
|
+
> `type` is fixed to `password` (and switches to `text` while revealed); setting it has no effect.
|
|
40
|
+
|
|
41
|
+
#### Methods
|
|
42
|
+
|
|
43
|
+
| Name | Description |
|
|
44
|
+
| ---------------------------- | ----------------------------------------------- |
|
|
45
|
+
| `togglePasswordVisibility()` | Toggles between the masked and revealed states. |
|
|
46
|
+
|
|
47
|
+
#### Events
|
|
48
|
+
|
|
49
|
+
| Name | Detail | Description |
|
|
50
|
+
| -------------- | -------------------- | ------------------------------------- |
|
|
51
|
+
| `input-change` | `string` (the value) | Fired when the input's value changes. |
|
|
52
|
+
|
|
53
|
+
#### CSS Custom Properties
|
|
54
|
+
|
|
55
|
+
Headless by default; the reveal button reads `--el-color-fg-muted`, `--el-color-accent`, `--el-focus-ring-width` and `--el-radius-sm`, and the field inherits `input-field`'s tokens (`--el-color-success`, `--el-color-danger`, `--el-font-size-sm`, `--el-space-*`). Skin it via a theme — see the Storybook _Docs / Theming_ page.
|
|
56
|
+
|
|
57
|
+
## Accessibility
|
|
58
|
+
|
|
59
|
+
- The reveal button is a real `<button>` with an `aria-label` that flips between "Show password" and "Hide password", and an `aria-pressed` state, so its purpose and state are announced.
|
|
60
|
+
- Validation messages surface only once the field is `touched` (inherited from `form-field`).
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const css = String.raw;
|
|
2
|
+
|
|
3
|
+
export default css`
|
|
4
|
+
el-password-field {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: var(--el-space-1, 4px);
|
|
8
|
+
|
|
9
|
+
.field {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: var(--el-space-2, 8px);
|
|
13
|
+
|
|
14
|
+
.validity {
|
|
15
|
+
.valid {
|
|
16
|
+
color: var(--el-color-success, green);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.invalid {
|
|
20
|
+
color: var(--el-color-danger, red);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.password-toggle {
|
|
26
|
+
display: inline-flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
flex: none;
|
|
30
|
+
padding: 0;
|
|
31
|
+
border: none;
|
|
32
|
+
border-radius: var(--el-radius-sm, 0);
|
|
33
|
+
background: transparent;
|
|
34
|
+
color: var(--el-color-fg-muted, inherit);
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
line-height: 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.password-toggle:disabled {
|
|
40
|
+
cursor: not-allowed;
|
|
41
|
+
opacity: 0.5;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.password-toggle:focus-visible {
|
|
45
|
+
outline: var(--el-focus-ring-width, 2px) solid var(--el-color-accent, currentColor);
|
|
46
|
+
outline-offset: 2px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.password-toggle svg {
|
|
50
|
+
width: 1.25em;
|
|
51
|
+
height: 1.25em;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.message {
|
|
55
|
+
font-size: var(--el-font-size-sm, 14px);
|
|
56
|
+
|
|
57
|
+
&.error-message {
|
|
58
|
+
color: var(--el-color-danger, red);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
6
|
+
|
|
7
|
+
<!--
|
|
8
|
+
When your PR touches this component, add an entry under Unreleased and
|
|
9
|
+
mirror it (prefixed with the component name) in root CHANGELOG.md.
|
|
10
|
+
Uncomment headings as needed.
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
## Unreleased
|
|
14
|
+
|
|
15
|
+
## [0.1.0] - 2026-06-03
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Initial release of `el-radio-field` — a single-choice radio group extending `FormField`. Renders a native `<fieldset>`/`<legend>` wrapping mutually-exclusive `<input type="radio">`s (native grouping, arrow-key navigation and form submission) with a custom, headless-by-default circular indicator.
|
|
20
|
+
- `options` property accepting plain strings or `{ value, label?, disabled? }` objects (mirrors `el-select-field`); `value` reflects the selected option.
|
|
21
|
+
- Inherits the `input-change` event and `touched` / `valid` / `invalid` custom states from `FormField`.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { html, defineElement } from '@webtides/element-js';
|
|
2
|
+
import FormField from '../form-field/form-field.js';
|
|
3
|
+
import style from './radio-field.style.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A single-choice radio group with a custom indicator, label, help text and validation. Renders a
|
|
7
|
+
* native `<fieldset>`/`<legend>` wrapping mutually-exclusive `<input type="radio">`s (so keyboard
|
|
8
|
+
* navigation, grouping and form submission are all native). Extends `FormField` and inherits its
|
|
9
|
+
* help / error / required / touched-state surface; the `label` becomes the group's `<legend>`.
|
|
10
|
+
*
|
|
11
|
+
* @element el-radio-field
|
|
12
|
+
*
|
|
13
|
+
* @fires {CustomEvent<string>} input-change - Fired when the selected value changes. `detail` is
|
|
14
|
+
* the newly selected value. Bubbles.
|
|
15
|
+
*
|
|
16
|
+
* @cssstate touched - Set once the user has focused and blurred the group. Inherits `valid` and
|
|
17
|
+
* `invalid` from `FormField`.
|
|
18
|
+
*
|
|
19
|
+
* @property {string} value - The selected option's value.
|
|
20
|
+
* @property {Array<string | { value: string, label?: string, disabled?: boolean }>} options -
|
|
21
|
+
* Options to render. Accepts plain strings (`['Yes', 'No']`) or option objects
|
|
22
|
+
* (`[{ value, label, disabled? }]`). Strings are used as both value and label.
|
|
23
|
+
*/
|
|
24
|
+
export default class RadioField extends FormField {
|
|
25
|
+
/** @private */
|
|
26
|
+
uuid = Math.random().toString(36).substr(2, 5);
|
|
27
|
+
|
|
28
|
+
constructor(options) {
|
|
29
|
+
super({ shadowRender: false, styles: [style], ...options });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
properties() {
|
|
33
|
+
return {
|
|
34
|
+
...super.properties(),
|
|
35
|
+
options: [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
connected() {
|
|
40
|
+
super.connected();
|
|
41
|
+
// Reflect validity (required-but-empty) so :state(invalid) is correct from the start; the
|
|
42
|
+
// message stays hidden until the group is touched.
|
|
43
|
+
this.valid = this._computeValid();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
events() {
|
|
47
|
+
return {
|
|
48
|
+
'input[type="radio"]': {
|
|
49
|
+
change: (event) => {
|
|
50
|
+
this.value = event.target.value;
|
|
51
|
+
this.valid = this._computeValid();
|
|
52
|
+
},
|
|
53
|
+
focus: () => this.onFocus(),
|
|
54
|
+
blur: () => this.onBlur(),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Whether the group currently passes validation. A radio group's only native constraint is
|
|
61
|
+
* `required`, so this is timing-independent (no rendered input needed): required ⇒ a value
|
|
62
|
+
* must be selected.
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
_computeValid() {
|
|
66
|
+
if (this.required) return this.value != null && this.value !== '';
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
onFocus() {
|
|
71
|
+
this.valid = this._computeValid();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
onBlur() {
|
|
75
|
+
this.touched = true;
|
|
76
|
+
this.valid = this._computeValid();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The label is rendered as the group's `<legend>` (see `template`), so the base FormField
|
|
81
|
+
* `<label>` is suppressed.
|
|
82
|
+
* @returns {null}
|
|
83
|
+
*/
|
|
84
|
+
labelTemplate() {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
template() {
|
|
89
|
+
return html`
|
|
90
|
+
<fieldset
|
|
91
|
+
class="field ${this.classes().field}"
|
|
92
|
+
aria-describedby="${this.name}-help-message"
|
|
93
|
+
aria-errormessage="${this.name}-error-message"
|
|
94
|
+
aria-invalid="${this.valid ? 'false' : 'true'}"
|
|
95
|
+
>
|
|
96
|
+
${this.legendTemplate()} ${this.helpTemplate()}
|
|
97
|
+
<div class="options">${this.fieldTemplate()}</div>
|
|
98
|
+
${this.errorTemplate()}
|
|
99
|
+
</fieldset>
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** @private */
|
|
104
|
+
legendTemplate() {
|
|
105
|
+
if (!this.label) return null;
|
|
106
|
+
return html` <legend class="${this.classes().label}">${this.label}</legend> `;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** @private */
|
|
110
|
+
fieldTemplate() {
|
|
111
|
+
return this.options.map((option, index) => {
|
|
112
|
+
const value = option.value ?? option;
|
|
113
|
+
const label = option.label ?? option;
|
|
114
|
+
const optionDisabled = this.disabled || !!option.disabled;
|
|
115
|
+
const checked = this.value != null && String(this.value) === String(value);
|
|
116
|
+
const id = `radio-${this.uuid}-${index}`;
|
|
117
|
+
|
|
118
|
+
return html`
|
|
119
|
+
<label class="option" for="${id}">
|
|
120
|
+
<input
|
|
121
|
+
type="radio"
|
|
122
|
+
id="${id}"
|
|
123
|
+
name="${this.name}"
|
|
124
|
+
value="${value}"
|
|
125
|
+
?checked="${checked}"
|
|
126
|
+
?disabled="${optionDisabled}"
|
|
127
|
+
?required="${this.required}"
|
|
128
|
+
aria-describedby="${this.name}-help-message"
|
|
129
|
+
/>
|
|
130
|
+
<span class="radio-indicator" aria-hidden="true"></span>
|
|
131
|
+
<span class="option-label">${label}</span>
|
|
132
|
+
</label>
|
|
133
|
+
`;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function define() {
|
|
139
|
+
defineElement('el-radio-field', RadioField);
|
|
140
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# RadioField
|
|
2
|
+
|
|
3
|
+
`radio-field` is a single-choice radio group. It renders a native `<fieldset>`/`<legend>` wrapping mutually-exclusive `<input type="radio">`s — so grouping, arrow-key navigation and form submission are all native — with a custom indicator on top. It extends `form-field`, inheriting the label, help text, error message, `required` and touched-state handling.
|
|
4
|
+
|
|
5
|
+
It is headless by default: without a theme the indicator falls back to a `currentColor` outline.
|
|
6
|
+
|
|
7
|
+
## How to use
|
|
8
|
+
|
|
9
|
+
#### Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm i --save @webtides/element-library
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
#### Use
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import '@webtides/element-library/radio-field/define';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<el-radio-field name="plan" label="Choose a plan" required="true"></el-radio-field>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
document.querySelector('el-radio-field').options = ['Starter', 'Pro', 'Enterprise'];
|
|
26
|
+
</script>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Options may be plain strings or objects with separate `value` / `label` and an optional per-option `disabled` flag:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
field.options = [
|
|
33
|
+
{ value: 'standard', label: 'Standard (free)' },
|
|
34
|
+
{ value: 'priority', label: 'Priority' },
|
|
35
|
+
{ value: 'dedicated', label: 'Dedicated (sold out)', disabled: true }
|
|
36
|
+
];
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
#### Properties/Attributes
|
|
42
|
+
|
|
43
|
+
Inherits all of `form-field`'s properties (`name`, `value`, `required`, `disabled`, `label`, `labelScreenReaderOnly`, `errorMessage`, `helpMessage`, `valid`, `touched`) and adds:
|
|
44
|
+
|
|
45
|
+
| Name | Type | Default | Description |
|
|
46
|
+
| --- | --- | --- | --- |
|
|
47
|
+
| `value` | `string` | `null` | The selected option's value. |
|
|
48
|
+
| `options` | `Array<string \| { value: string, label?: string, disabled?: boolean }>` | `[]` | Options to render. Strings are used as both value and label; objects allow a separate label/disabled. |
|
|
49
|
+
|
|
50
|
+
#### Events
|
|
51
|
+
|
|
52
|
+
| Name | Detail | Description |
|
|
53
|
+
| -------------- | -------------------- | -------------------------------------- |
|
|
54
|
+
| `input-change` | `string` (the value) | Fired when the selected value changes. |
|
|
55
|
+
|
|
56
|
+
#### CSS States
|
|
57
|
+
|
|
58
|
+
| Name | Description |
|
|
59
|
+
| --------- | ------------------------------------------------------------------------- |
|
|
60
|
+
| `touched` | Set once the group has been focused and blurred. |
|
|
61
|
+
| `valid` | Set while the group passes validation. |
|
|
62
|
+
| `invalid` | Set while the group fails validation (e.g. `required` with no selection). |
|
|
63
|
+
|
|
64
|
+
#### CSS Custom Properties
|
|
65
|
+
|
|
66
|
+
Headless by default; reads the library's `--el-*` design tokens (`--el-color-accent`, `--el-color-border`, `--el-color-bg`, `--el-space-*`, `--el-border-width`, `--el-focus-ring-width`, `--el-duration-md`, `--el-ease`, `--el-color-fg-muted`, `--el-color-danger`). Skin it via a theme — see the Storybook _Docs / Theming_ page.
|
|
67
|
+
|
|
68
|
+
## Accessibility
|
|
69
|
+
|
|
70
|
+
- Uses a native `<fieldset>` + `<legend>`, so the group is announced with its label and radios are mutually exclusive with native arrow-key navigation.
|
|
71
|
+
- The native radio stays in the accessibility tree and focusable; it is only hidden visually, with keyboard focus reflected onto the custom indicator via `:focus-visible`.
|
|
72
|
+
- Validation messages surface only once the group is `touched`.
|