@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,108 @@
|
|
|
1
|
+
const css = String.raw;
|
|
2
|
+
|
|
3
|
+
export default css`
|
|
4
|
+
el-radio-field {
|
|
5
|
+
display: block;
|
|
6
|
+
|
|
7
|
+
fieldset.field {
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 0;
|
|
10
|
+
border: 0;
|
|
11
|
+
min-width: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
legend {
|
|
15
|
+
padding: 0;
|
|
16
|
+
margin-bottom: var(--el-space-1, 0);
|
|
17
|
+
color: var(--el-color-fg, inherit);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.options {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: var(--el-space-2, 0.5em);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.option {
|
|
27
|
+
display: inline-flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: var(--el-space-2, 0.5em);
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.option:has(input:disabled) {
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* The native radio is replaced by .radio-indicator; hide it visually but keep it in the
|
|
38
|
+
accessibility tree and focusable. */
|
|
39
|
+
input[type='radio'] {
|
|
40
|
+
position: absolute;
|
|
41
|
+
width: 1px;
|
|
42
|
+
height: 1px;
|
|
43
|
+
margin: 0;
|
|
44
|
+
padding: 0;
|
|
45
|
+
border: 0;
|
|
46
|
+
opacity: 0;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
clip: rect(0 0 0 0);
|
|
50
|
+
clip-path: inset(50%);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Reflect keyboard focus onto the custom indicator. */
|
|
54
|
+
input[type='radio']:focus-visible + .radio-indicator {
|
|
55
|
+
outline: var(--el-focus-ring-width, 2px) solid var(--el-color-accent, currentColor);
|
|
56
|
+
outline-offset: 2px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.radio-indicator {
|
|
60
|
+
display: inline-flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
flex: none;
|
|
64
|
+
/* Fallbacks render a usable circle even without a theme, since the native input is hidden. */
|
|
65
|
+
width: var(--el-space-4, 1em);
|
|
66
|
+
height: var(--el-space-4, 1em);
|
|
67
|
+
border: var(--el-border-width, 1px) solid var(--el-color-border, currentColor);
|
|
68
|
+
border-radius: 50%;
|
|
69
|
+
background: var(--el-color-bg, transparent);
|
|
70
|
+
transition: border-color var(--el-duration-md, 0s) var(--el-ease, linear);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* The filled dot scales in when the option is selected (driven by :checked, no host state). */
|
|
74
|
+
.radio-indicator::after {
|
|
75
|
+
content: '';
|
|
76
|
+
width: 50%;
|
|
77
|
+
height: 50%;
|
|
78
|
+
border-radius: 50%;
|
|
79
|
+
background: var(--el-color-accent, currentColor);
|
|
80
|
+
transform: scale(0);
|
|
81
|
+
transition: transform var(--el-duration-md, 0s) var(--el-ease, linear);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
input[type='radio']:checked + .radio-indicator {
|
|
85
|
+
border-color: var(--el-color-accent, currentColor);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
input[type='radio']:checked + .radio-indicator::after {
|
|
89
|
+
transform: scale(1);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
input[type='radio']:disabled + .radio-indicator {
|
|
93
|
+
opacity: 0.5;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.message {
|
|
97
|
+
display: block;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.help-message {
|
|
101
|
+
color: var(--el-color-fg-muted, inherit);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.error-message {
|
|
105
|
+
color: var(--el-color-danger, inherit);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
`;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
<!-- ### Added -->
|
|
15
|
+
<!-- ### Changed -->
|
|
16
|
+
<!-- ### Removed -->
|
|
17
|
+
<!-- ### Fixed -->
|
|
18
|
+
|
|
19
|
+
## [0.1.0] - 2026-06-03
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Migrated into the single-repo `@webtides/element-library` package. No API changes.
|
|
24
|
+
|
|
25
|
+
## Legacy (pre-merge)
|
|
26
|
+
|
|
27
|
+
The version numbers below predate the single-package merge and refer to the component's former standalone npm package, not the current `@webtides/element-library` version. Kept for historical reference.
|
|
28
|
+
|
|
29
|
+
## 0.1.1 (2021-07-21)
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
update element-js version
|
|
34
|
+
|
|
35
|
+
## 0.1.0 (2020-03-15)
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- initial release
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BaseElement, defineElement } from '@webtides/element-js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wraps any click-emitting child (`<a>`, `<button>`, …) and scrolls to the element
|
|
5
|
+
* matched by `selector` when the child is clicked.
|
|
6
|
+
*
|
|
7
|
+
* @element el-scroll-to
|
|
8
|
+
*
|
|
9
|
+
* @slot - Default slot. Any child that emits a `click` event will trigger the scroll.
|
|
10
|
+
*
|
|
11
|
+
* @property {string} selector - CSS selector for the element to scroll into view on click.
|
|
12
|
+
* @property {boolean} preventDefault - When `true`, the captured click's default action is
|
|
13
|
+
* suppressed (e.g. an `<a href>`'s navigation).
|
|
14
|
+
*/
|
|
15
|
+
export default class ScrollTo extends BaseElement {
|
|
16
|
+
properties() {
|
|
17
|
+
return {
|
|
18
|
+
selector: '',
|
|
19
|
+
preventDefault: true,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
events() {
|
|
24
|
+
return {
|
|
25
|
+
this: {
|
|
26
|
+
click: (e) => {
|
|
27
|
+
if (this.preventDefault === true) e.preventDefault();
|
|
28
|
+
document.querySelector(this.selector)?.scrollIntoView({
|
|
29
|
+
behavior: 'auto',
|
|
30
|
+
block: 'start',
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function define() {
|
|
39
|
+
defineElement('el-scroll-to', ScrollTo);
|
|
40
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# ScrollTo
|
|
2
|
+
|
|
3
|
+
`scroll-to` is a wrapper that smoothly scrolls to another element on the page. Point it at a target with any CSS selector; any `click`-emitting child element (e.g. `<a>` or `<button>`) triggers the scroll.
|
|
4
|
+
|
|
5
|
+
## How to use
|
|
6
|
+
|
|
7
|
+
#### Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i --save @webtides/element-library
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### Use
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import '@webtides/element-library/scroll-to/define';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<el-scroll-to selector="#highlights-section">
|
|
21
|
+
<a>Highlights</a>
|
|
22
|
+
</el-scroll-to>
|
|
23
|
+
<!-- some in between content ... -->
|
|
24
|
+
<section id="highlights-section"></section>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
#### Properties/Attribute
|
|
30
|
+
|
|
31
|
+
| Name | Type | Default | Description |
|
|
32
|
+
| --- | --- | --- | --- |
|
|
33
|
+
| `selector` | `string` | `''` | A [`DOMString`](https://developer.mozilla.org/en-US/docs/Web/API/DOMString) containing one selector to match. This string must be a valid CSS selector string. See [Locating DOM elements using selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors) for more about selectors and how to manage them. |
|
|
34
|
+
| `preventDefault` | `boolean` | `true` | The Event interface's preventDefault() method tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be. The event continues to propagate as usual. |
|
|
35
|
+
|
|
36
|
+
#### Methods
|
|
37
|
+
|
|
38
|
+
_None_
|
|
39
|
+
|
|
40
|
+
#### Events
|
|
41
|
+
|
|
42
|
+
_None_
|
|
43
|
+
|
|
44
|
+
#### CSS Custom Properties
|
|
45
|
+
|
|
46
|
+
_None_
|
|
47
|
+
|
|
48
|
+
#### Slots
|
|
49
|
+
|
|
50
|
+
_None_
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
<!-- ### Added -->
|
|
15
|
+
<!-- ### Changed -->
|
|
16
|
+
<!-- ### Removed -->
|
|
17
|
+
<!-- ### Fixed -->
|
|
18
|
+
|
|
19
|
+
## [0.1.0] - 2026-06-03
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Migrated into the single-repo `@webtides/element-library` package. No API changes.
|
|
24
|
+
|
|
25
|
+
## Legacy (pre-merge)
|
|
26
|
+
|
|
27
|
+
The version numbers below predate the single-package merge and refer to the component's former standalone npm package, not the current `@webtides/element-library` version. Kept for historical reference.
|
|
28
|
+
|
|
29
|
+
## 0.1.1 (2021-07-21)
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
update element-js version
|
|
34
|
+
|
|
35
|
+
## 0.1.0 (2020-03-15)
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- initial release
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { StyledElement, defineElement } from '@webtides/element-js';
|
|
2
|
+
import style from './scroll-to-top.style.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Wraps any click-emitting child (`<a>`, `<button>`, …) and smoothly scrolls the window
|
|
6
|
+
* to the top when the child is clicked.
|
|
7
|
+
*
|
|
8
|
+
* @element el-scroll-to-top
|
|
9
|
+
*
|
|
10
|
+
* @slot - Default slot. Any child that emits a `click` event will trigger the scroll.
|
|
11
|
+
*
|
|
12
|
+
* @property {number} duration - Duration of the easing animation in milliseconds. Ignored
|
|
13
|
+
* when the page's `html` element has `scroll-behavior: smooth` (the browser drives the
|
|
14
|
+
* scroll in that case).
|
|
15
|
+
* @property {boolean} preventDefault - When `true`, the captured click's default action is
|
|
16
|
+
* suppressed.
|
|
17
|
+
*/
|
|
18
|
+
export default class ScrollToTop extends StyledElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super({ styles: [style] });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
properties() {
|
|
24
|
+
return {
|
|
25
|
+
duration: 1000,
|
|
26
|
+
preventDefault: true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
connected() {
|
|
31
|
+
// TODO: find a more generic way of dealing with cloaking
|
|
32
|
+
// maybe use a mixin for cloaking?!
|
|
33
|
+
this.removeAttribute('cloak');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
events() {
|
|
37
|
+
return {
|
|
38
|
+
this: {
|
|
39
|
+
click: (e) => {
|
|
40
|
+
if (this.preventDefault) e.preventDefault();
|
|
41
|
+
this.scrollToTop();
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Scroll the window to the top.
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
scrollToTop() {
|
|
52
|
+
const htmlScroll = window
|
|
53
|
+
.getComputedStyle(document.querySelectorAll('html')[0], null)
|
|
54
|
+
.getPropertyValue('scroll-behavior');
|
|
55
|
+
|
|
56
|
+
if (htmlScroll === 'smooth') {
|
|
57
|
+
window.scrollTo(0, 0);
|
|
58
|
+
} else {
|
|
59
|
+
const duration = this.duration;
|
|
60
|
+
const difference = document.documentElement.scrollTop || document.body.scrollTop;
|
|
61
|
+
const startTime = performance.now();
|
|
62
|
+
|
|
63
|
+
// noinspection JSAnnotator
|
|
64
|
+
function step(timeStamp) {
|
|
65
|
+
let normalizedTime = (timeStamp - startTime) / duration;
|
|
66
|
+
if (normalizedTime > 1) normalizedTime = 1;
|
|
67
|
+
|
|
68
|
+
window.scrollTo(0, difference * Math.cos(normalizedTime * Math.PI));
|
|
69
|
+
if (normalizedTime < 1) window.requestAnimationFrame(step);
|
|
70
|
+
}
|
|
71
|
+
window.requestAnimationFrame(step);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function define() {
|
|
77
|
+
defineElement('el-scroll-to-top', ScrollToTop);
|
|
78
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# ScrollToTop
|
|
2
|
+
|
|
3
|
+
`scroll-to-top` is a wrapper that smoothly scrolls the page to the top. Place any `click`-emitting child element inside (e.g. `<a>` or `<button>`); when it fires a `click`, `scroll-to-top` captures it and scrolls to the top.
|
|
4
|
+
|
|
5
|
+
## How to use
|
|
6
|
+
|
|
7
|
+
#### Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i --save @webtides/element-library
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### Use
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import '@webtides/element-library/scroll-to-top/define';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<el-scroll-to-top>
|
|
21
|
+
<button>Scroll to top</button>
|
|
22
|
+
</el-scroll-to-top>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
#### Properties/Attribute
|
|
28
|
+
|
|
29
|
+
| Name | Type | Default | Description |
|
|
30
|
+
| --- | --- | --- | --- |
|
|
31
|
+
| `duration` | `number` | `1000` | Time in milliseconds the animation should take. |
|
|
32
|
+
| `preventDefault` | `boolean` | `true` | The Event interface's preventDefault() method tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be. The event continues to propagate as usual. |
|
|
33
|
+
|
|
34
|
+
#### Methods
|
|
35
|
+
|
|
36
|
+
_None_
|
|
37
|
+
|
|
38
|
+
#### Events
|
|
39
|
+
|
|
40
|
+
_None_
|
|
41
|
+
|
|
42
|
+
#### CSS Custom Properties
|
|
43
|
+
|
|
44
|
+
_None_
|
|
45
|
+
|
|
46
|
+
#### Slots
|
|
47
|
+
|
|
48
|
+
_None_
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- BREAKING: renamed the dropdown indicator's CSS class from `.icon` to `.dropdown-indicator` to avoid collisions with generic consumer styles.
|
|
20
|
+
- The `.dropdown-indicator` now renders an SVG chevron (inheriting `currentColor`) instead of the `∨` text glyph, for a crisp, consistent caret. Still hidden by default and shown/positioned by the themes.
|
|
21
|
+
|
|
22
|
+
## Legacy (pre-merge)
|
|
23
|
+
|
|
24
|
+
The version numbers below predate the single-package merge and refer to the component's former standalone npm package, not the current `@webtides/element-library` version. Kept for historical reference.
|
|
25
|
+
|
|
26
|
+
## [0.1.0] - 2024-06-18
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- initial release
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { html, defineElement, classMap, when } from '@webtides/element-js';
|
|
2
|
+
import FormField from '../form-field/form-field.js';
|
|
3
|
+
import style from './select-field.style.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Native `<select>` wrapper with label, help text, validation feedback and a custom
|
|
7
|
+
* dropdown indicator. Extends `FormField` and inherits its label / help / error /
|
|
8
|
+
* required surface.
|
|
9
|
+
*
|
|
10
|
+
* @element el-select-field
|
|
11
|
+
*
|
|
12
|
+
* @fires {CustomEvent<string>} input-change - Fired when the selected value changes.
|
|
13
|
+
* `detail` is the new value. Bubbles.
|
|
14
|
+
*
|
|
15
|
+
* @property {string} placeholder - Placeholder text rendered as the first disabled `<option>`
|
|
16
|
+
* when no selection has been made.
|
|
17
|
+
* @property {Array<string | { value: string, label?: string, selected?: boolean }>} options -
|
|
18
|
+
* Options to render. Accepts plain strings (`['Apple', 'Pear']`) or option objects
|
|
19
|
+
* (`[{ value, label, selected? }]`). Strings are used as both value and label.
|
|
20
|
+
*/
|
|
21
|
+
export default class SelectField extends FormField {
|
|
22
|
+
constructor() {
|
|
23
|
+
super({ styles: [style] });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
properties() {
|
|
27
|
+
return {
|
|
28
|
+
...super.properties(),
|
|
29
|
+
placeholder: '',
|
|
30
|
+
options: [],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** @private */
|
|
35
|
+
fieldTemplate() {
|
|
36
|
+
return html`
|
|
37
|
+
<select
|
|
38
|
+
ref="input"
|
|
39
|
+
id="input-${this.name}"
|
|
40
|
+
name="${this.name}"
|
|
41
|
+
value="${this.value}"
|
|
42
|
+
?required="${this.required}"
|
|
43
|
+
?disabled="${this.disabled}"
|
|
44
|
+
aria-describedby="${this.name}-help-message"
|
|
45
|
+
aria-invalid="${this.valid ? 'false' : 'true'}"
|
|
46
|
+
aria-errormessage="${this.name}-error-message"
|
|
47
|
+
>
|
|
48
|
+
${when(this.placeholder, html` <option value="" selected disabled>${this.placeholder}</option> `)}
|
|
49
|
+
${this.options.map((option) => {
|
|
50
|
+
const value = option.value ?? option;
|
|
51
|
+
return html`
|
|
52
|
+
<option value="${value}" ?selected=${option.selected && !!option.selected}>
|
|
53
|
+
${option.label ?? option}
|
|
54
|
+
</option>
|
|
55
|
+
`;
|
|
56
|
+
})}
|
|
57
|
+
</select>
|
|
58
|
+
${this.dropdownIndicatorTemplate()}
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** @private */
|
|
63
|
+
dropdownIndicatorTemplate() {
|
|
64
|
+
return html`
|
|
65
|
+
<div class="dropdown-indicator" aria-hidden="true">
|
|
66
|
+
<svg
|
|
67
|
+
viewBox="0 0 24 24"
|
|
68
|
+
fill="none"
|
|
69
|
+
stroke="currentColor"
|
|
70
|
+
stroke-width="2"
|
|
71
|
+
stroke-linecap="round"
|
|
72
|
+
stroke-linejoin="round"
|
|
73
|
+
>
|
|
74
|
+
<polyline points="6 9 12 15 18 9"></polyline>
|
|
75
|
+
</svg>
|
|
76
|
+
</div>
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function define() {
|
|
82
|
+
defineElement('el-select-field', SelectField);
|
|
83
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# SelectField
|
|
2
|
+
|
|
3
|
+
`select-field` is a web component that wraps the native HTML `<select>` element with enhanced functionality including label management, validation states, error messages, help text, and accessibility features. It extends the base `FormField` component and provides a complete dropdown selection solution with built-in validation feedback and a custom dropdown indicator.
|
|
4
|
+
|
|
5
|
+
## How to use
|
|
6
|
+
|
|
7
|
+
#### Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i --save @webtides/element-library
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### Use
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import '@webtides/element-library/select-field/define';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<!-- Simple string array options -->
|
|
21
|
+
<el-select-field
|
|
22
|
+
name="country"
|
|
23
|
+
label="Country"
|
|
24
|
+
placeholder="Select a country"
|
|
25
|
+
options='["USA", "Canada", "Mexico"]'
|
|
26
|
+
help-message="Choose your country of residence"
|
|
27
|
+
error-message="Please select a country"
|
|
28
|
+
required
|
|
29
|
+
></el-select-field>
|
|
30
|
+
|
|
31
|
+
<!-- Object-based options with values and labels -->
|
|
32
|
+
<el-select-field
|
|
33
|
+
name="size"
|
|
34
|
+
label="Size"
|
|
35
|
+
placeholder="Select a size"
|
|
36
|
+
options='[
|
|
37
|
+
{"value": "sm", "label": "Small"},
|
|
38
|
+
{"value": "md", "label": "Medium", "selected": true},
|
|
39
|
+
{"value": "lg", "label": "Large"}
|
|
40
|
+
]'
|
|
41
|
+
></el-select-field>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
#### Properties/Attributes
|
|
47
|
+
|
|
48
|
+
| Name | Type | Default | Description |
|
|
49
|
+
| --- | --- | --- | --- |
|
|
50
|
+
| `name` | `string` | `''` | The name attribute for the select field, used for form submission and identification |
|
|
51
|
+
| `value` | `string` | `null` | The current selected value of the select field |
|
|
52
|
+
| `placeholder` | `string` | `''` | Placeholder text displayed as the first disabled option when no selection is made |
|
|
53
|
+
| `options` | `Array<string\|object>` | `[]` | Array of options. Can be simple strings or objects with `value`, `label`, and `selected` properties |
|
|
54
|
+
| `required` | `boolean` | `false` | Whether the field is required for form submission |
|
|
55
|
+
| `disabled` | `boolean` | `false` | Whether the field is disabled and cannot be interacted with |
|
|
56
|
+
| `label` | `string` | `''` | Label text displayed above the select field |
|
|
57
|
+
| `labelScreenReaderOnly` | `boolean` | `false` | Whether to visually hide the label while keeping it accessible to screen readers |
|
|
58
|
+
| `helpMessage` | `string` | `''` | Help text displayed below the label to provide additional context |
|
|
59
|
+
| `errorMessage` | `string` | `''` | Error message displayed when validation fails and field is touched |
|
|
60
|
+
| `valid` | `boolean` | `true` | Whether the current selected value is valid according to the field's constraints |
|
|
61
|
+
| `touched` | `boolean` | `false` | Whether the user has interacted with the field (focused and blurred) |
|
|
62
|
+
|
|
63
|
+
#### Options Format
|
|
64
|
+
|
|
65
|
+
The `options` property accepts two formats:
|
|
66
|
+
|
|
67
|
+
**Simple strings:**
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
["Option 1", "Option 2", "Option 3"]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Objects with properties:**
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
[
|
|
77
|
+
{ "value": "opt1", "label": "Option 1" },
|
|
78
|
+
{ "value": "opt2", "label": "Option 2", "selected": true },
|
|
79
|
+
{ "value": "opt3", "label": "Option 3" }
|
|
80
|
+
]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
When using objects:
|
|
84
|
+
|
|
85
|
+
- `value`: The value submitted with the form (defaults to the string if not provided)
|
|
86
|
+
- `label`: The text displayed in the dropdown (defaults to the string if not provided)
|
|
87
|
+
- `selected`: Whether this option should be pre-selected (optional)
|
|
88
|
+
|
|
89
|
+
#### Methods
|
|
90
|
+
|
|
91
|
+
| Name | Parameters | Description |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| `onFocus()` | None | Internal method called when select receives focus, updates validation state |
|
|
94
|
+
| `onBlur()` | None | Internal method called when select loses focus, marks field as touched and updates validation |
|
|
95
|
+
| `onChange()` | None | Internal method called when selection changes, updates value and validation state |
|
|
96
|
+
| `dropdownIndicatorTemplate()` | None | Returns the template for the dropdown indicator icon (∨) |
|
|
97
|
+
|
|
98
|
+
#### Events
|
|
99
|
+
|
|
100
|
+
| Name | Detail | Description |
|
|
101
|
+
| -------------- | ---------------- | ---------------------------------------------------------------------- |
|
|
102
|
+
| `input-change` | `value` (string) | Dispatched when the selected value changes. Bubbles up through the DOM |
|
|
103
|
+
|
|
104
|
+
#### CSS Custom Properties
|
|
105
|
+
|
|
106
|
+
This component is headless by default and inherits its styling — and the `--el-*` design tokens it reads — from `FormField`, plus a custom dropdown indicator. Skin it by setting those tokens via a theme — see the Storybook _Docs / Theming_ page.
|
|
107
|
+
|
|
108
|
+
#### Slots
|
|
109
|
+
|
|
110
|
+
_None_ - The component generates its own select element and options internally
|
|
111
|
+
|
|
112
|
+
## Accessibility
|
|
113
|
+
|
|
114
|
+
- Includes proper ARIA attributes (`aria-describedby`, `aria-invalid`, `aria-errormessage`)
|
|
115
|
+
- Links labels to select elements via `for` attribute
|
|
116
|
+
- Supports screen reader only labels
|
|
117
|
+
- Error messages are properly associated with the select field
|
|
118
|
+
- Placeholder option is disabled to prevent invalid submissions
|
|
119
|
+
|
|
120
|
+
## Validation
|
|
121
|
+
|
|
122
|
+
The component provides validation feedback:
|
|
123
|
+
|
|
124
|
+
- Validation state updates on focus, blur, and change events
|
|
125
|
+
- Error messages display when field is touched and invalid
|
|
126
|
+
- Supports HTML5 validation (required attribute)
|
|
127
|
+
- Inherits validation behavior from the base `FormField` component
|
|
128
|
+
|
|
129
|
+
## Customization
|
|
130
|
+
|
|
131
|
+
The dropdown indicator can be customized by extending the component and overriding the `dropdownIndicatorTemplate()` method to return custom HTML/SVG icons.
|