@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,40 @@
|
|
|
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-10-07
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- Basic amount-field
|
|
40
|
+
- initial release
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { TemplateElement, defineElement, html } from '@webtides/element-js';
|
|
2
|
+
import FormField from '../form-field/form-field.js';
|
|
3
|
+
import style from './amount-field.style.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Numeric amount stepper input. Renders a readonly `<input type="number">` flanked by
|
|
7
|
+
* increment (`+`) and decrement (`-`) buttons, with optional `min` and `max` bounds.
|
|
8
|
+
* Extends `FormField` and inherits its label, help and validation surface.
|
|
9
|
+
*
|
|
10
|
+
* @element el-amount-field
|
|
11
|
+
*
|
|
12
|
+
* @slot plus - Replaces the default `+` glyph in the increment button.
|
|
13
|
+
* @slot minus - Replaces the default `-` glyph in the decrement button.
|
|
14
|
+
*
|
|
15
|
+
* @csspart wrapper - The outer container around the input and stepper buttons.
|
|
16
|
+
* @csspart button - Applied to both stepper buttons.
|
|
17
|
+
* @csspart plus - Applied to the increment button (in addition to `button`).
|
|
18
|
+
* @csspart minus - Applied to the decrement button (in addition to `button`).
|
|
19
|
+
* @csspart input - The numeric input element.
|
|
20
|
+
*
|
|
21
|
+
* @property {string} name - Form name for the underlying `<input>` element.
|
|
22
|
+
* @property {number} value - Current numeric value of the field.
|
|
23
|
+
* @property {number | false} max - Upper bound. Set to `false` to leave the value unbounded
|
|
24
|
+
* above.
|
|
25
|
+
* @property {number | false} min - Lower bound. Set to `false` to leave the value unbounded
|
|
26
|
+
* below.
|
|
27
|
+
*/
|
|
28
|
+
export default class AmountField extends FormField {
|
|
29
|
+
constructor() {
|
|
30
|
+
super({ styles: [style], shadowRender: true });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
properties() {
|
|
34
|
+
return {
|
|
35
|
+
...super.properties(),
|
|
36
|
+
name: 'amount',
|
|
37
|
+
value: 1,
|
|
38
|
+
max: false,
|
|
39
|
+
min: 0,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
events() {
|
|
44
|
+
return {
|
|
45
|
+
'[ref=plus]': {
|
|
46
|
+
click: () => {
|
|
47
|
+
this.value++;
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
'[ref=minus]': {
|
|
51
|
+
click: () => {
|
|
52
|
+
this.value--;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
'[ref=input]': {
|
|
56
|
+
change: () => this.requestUpdate(),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
template() {
|
|
62
|
+
return html`
|
|
63
|
+
<div part="wrapper">
|
|
64
|
+
<button ref="plus" part="button plus" ?disabled="${this.max !== false && this.value >= this.max}">
|
|
65
|
+
<slot name="plus">+</slot>
|
|
66
|
+
</button>
|
|
67
|
+
<input
|
|
68
|
+
ref="input"
|
|
69
|
+
part="input"
|
|
70
|
+
type="number"
|
|
71
|
+
readonly="true"
|
|
72
|
+
id="input-${this.name}"
|
|
73
|
+
name="${this.name}"
|
|
74
|
+
?required="${this.required}"
|
|
75
|
+
?disabled="${this.disabled}"
|
|
76
|
+
value="${this.value}"
|
|
77
|
+
max="${this.max}"
|
|
78
|
+
min="${this.min}"
|
|
79
|
+
aria-describedby="${this.name}-help"
|
|
80
|
+
/>
|
|
81
|
+
<button ref="minus" part="button minus" ?disabled="${this.min !== false && this.value <= this.min}">
|
|
82
|
+
<slot name="minus">-</slot>
|
|
83
|
+
</button>
|
|
84
|
+
</div>
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function define() {
|
|
90
|
+
defineElement('el-amount-field', AmountField);
|
|
91
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# AmountField
|
|
2
|
+
|
|
3
|
+
`amount-field` is a numeric amount stepper input. It renders a readonly `<input type="number">` flanked by increment (`+`) and decrement (`-`) buttons, with optional `min` and `max` bounds. It extends the base `FormField` component and inherits its label, help and validation surface.
|
|
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/amount-field/define';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<el-amount-field name="quantity" value="1" min="0" max="10" label="Quantity"></el-amount-field>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## API
|
|
24
|
+
|
|
25
|
+
#### Properties/Attributes
|
|
26
|
+
|
|
27
|
+
| Name | Type | Default | Description |
|
|
28
|
+
| ------- | ----------------- | ---------- | --------------------------------------------------------------- |
|
|
29
|
+
| `name` | `string` | `'amount'` | Form name for the underlying `<input>` element. |
|
|
30
|
+
| `value` | `number` | `1` | Current numeric value of the field. |
|
|
31
|
+
| `min` | `number \| false` | `0` | Lower bound. Set to `false` to leave the value unbounded below. |
|
|
32
|
+
| `max` | `number \| false` | `false` | Upper bound. Set to `false` to leave the value unbounded above. |
|
|
33
|
+
|
|
34
|
+
Inherits the remaining form properties (`required`, `disabled`, `label`, `helpMessage`, `errorMessage`, `valid`, `touched`, …) from [`FormField`](../form-field/form-field.readme.md).
|
|
35
|
+
|
|
36
|
+
#### Methods
|
|
37
|
+
|
|
38
|
+
_Inherits methods from the `FormField` component._
|
|
39
|
+
|
|
40
|
+
#### Events
|
|
41
|
+
|
|
42
|
+
| Name | Detail | Description |
|
|
43
|
+
| -------------- | ------- | ------------------------------------------------------------------------------------- |
|
|
44
|
+
| `input-change` | `value` | Inherited from `FormField`. Fired when the value changes. Bubbles up through the DOM. |
|
|
45
|
+
|
|
46
|
+
#### Slots
|
|
47
|
+
|
|
48
|
+
| Name | Description |
|
|
49
|
+
| ------- | ------------------------------------------------------- |
|
|
50
|
+
| `plus` | Replaces the default `+` glyph in the increment button. |
|
|
51
|
+
| `minus` | Replaces the default `-` glyph in the decrement button. |
|
|
52
|
+
|
|
53
|
+
#### CSS Parts
|
|
54
|
+
|
|
55
|
+
| Name | Description |
|
|
56
|
+
| --------- | ---------------------------------------------------------- |
|
|
57
|
+
| `wrapper` | The outer container around the input and stepper buttons. |
|
|
58
|
+
| `button` | Applied to both stepper buttons. |
|
|
59
|
+
| `plus` | Applied to the increment button (in addition to `button`). |
|
|
60
|
+
| `minus` | Applied to the decrement button (in addition to `button`). |
|
|
61
|
+
| `input` | The numeric input element. |
|
|
62
|
+
|
|
63
|
+
#### CSS Custom Properties
|
|
64
|
+
|
|
65
|
+
This component is headless by default and reads the library's `--el-*` design tokens (e.g. `--el-color-bg`, `--el-color-border`, `--el-radius-md`, `--el-touch-target`). Skin it by setting these via a theme — see the Storybook _Docs / Theming_ page.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const css = String.raw;
|
|
2
|
+
|
|
3
|
+
export default css`
|
|
4
|
+
[part='wrapper'] {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: row;
|
|
7
|
+
align-items: center;
|
|
8
|
+
border: var(--el-border-width, 0) solid var(--el-color-border, transparent);
|
|
9
|
+
border-radius: var(--el-radius-md, 0);
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
width: fit-content;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
[part~='button'] {
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
background: var(--el-color-bg-muted, transparent);
|
|
17
|
+
color: var(--el-color-fg, inherit);
|
|
18
|
+
border: 0;
|
|
19
|
+
padding: var(--el-space-2, 0) var(--el-space-3, 0);
|
|
20
|
+
min-height: var(--el-touch-target, auto);
|
|
21
|
+
font: inherit;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[part~='button']:hover:not(:disabled) {
|
|
25
|
+
background: var(--el-color-border, transparent);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
[part~='button']:disabled {
|
|
29
|
+
opacity: 0.5;
|
|
30
|
+
cursor: not-allowed;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[part='input'] {
|
|
34
|
+
text-align: center;
|
|
35
|
+
appearance: none;
|
|
36
|
+
-webkit-appearance: none;
|
|
37
|
+
-moz-appearance: textfield;
|
|
38
|
+
border: 0;
|
|
39
|
+
background: var(--el-color-bg, transparent);
|
|
40
|
+
color: var(--el-color-fg, inherit);
|
|
41
|
+
padding: var(--el-space-2, 0) var(--el-space-3, 0);
|
|
42
|
+
min-width: var(--el-touch-target, auto);
|
|
43
|
+
font: inherit;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[part='input']:focus {
|
|
47
|
+
outline: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
input[type='number'] {
|
|
51
|
+
-moz-appearance: textfield;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
input[type='number']::-webkit-outer-spin-button,
|
|
55
|
+
input[type='number']::-webkit-inner-spin-button {
|
|
56
|
+
-webkit-appearance: none;
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 `el-button` — a themeable button modelled on Shoelace's `<sl-button>`. Renders a native `<button>`, or an `<a>` when `href` is set. Supports `variant` (`default / primary / success / neutral / warning / danger / text`), `size` (`small / medium / large`), `outline`, `pill`, `circle`, `caret`, `loading` and `disabled`; `prefix` / `suffix` icon slots; `base / prefix / label / suffix / caret / spinner` CSS parts; and `focus()` / `blur()` / `click()` methods. `type="submit"` / `type="reset"` drive the nearest ancestor `<form>` across the shadow boundary. Styling reads the `--el-*` design tokens, so it re-skins with every theme.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { TemplateElement, defineElement, html, classMap, spreadAttributes } from '@webtides/element-js';
|
|
2
|
+
import style from './button.style.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A themeable button that renders a native `<button>` — or an `<a>` when `href` is set — and
|
|
6
|
+
* decorates it with the `--el-*` design tokens. Supports semantic variants, sizes, outline /
|
|
7
|
+
* pill / circle shapes, an optional dropdown caret and a loading spinner. API modelled on
|
|
8
|
+
* Shoelace's `<sl-button>`.
|
|
9
|
+
*
|
|
10
|
+
* @element el-button
|
|
11
|
+
*
|
|
12
|
+
* @slot - The button's label.
|
|
13
|
+
* @slot prefix - A presentational prefix icon or similar element.
|
|
14
|
+
* @slot suffix - A presentational suffix icon or similar element.
|
|
15
|
+
*
|
|
16
|
+
* @csspart base - The internal `<button>` / `<a>`. The surface for background, border, radius.
|
|
17
|
+
* @csspart prefix - Container wrapping the `prefix` slot.
|
|
18
|
+
* @csspart label - The default-slot label wrapper.
|
|
19
|
+
* @csspart suffix - Container wrapping the `suffix` slot.
|
|
20
|
+
* @csspart caret - The dropdown caret, present only while `caret` is `true`.
|
|
21
|
+
* @csspart spinner - The loading spinner, present only while `loading` is `true`.
|
|
22
|
+
*
|
|
23
|
+
* @property {'default'|'primary'|'success'|'neutral'|'warning'|'danger'|'text'} variant - Visual
|
|
24
|
+
* variant. Default `'default'`.
|
|
25
|
+
* @property {'small'|'medium'|'large'} size - Button size. Default `'medium'`.
|
|
26
|
+
* @property {boolean} outline - Draws the button as an outline (transparent fill, colored border).
|
|
27
|
+
* @property {boolean} pill - Fully rounded ends.
|
|
28
|
+
* @property {boolean} circle - Renders a square, fully-rounded icon button (use with a single icon).
|
|
29
|
+
* @property {boolean} caret - Appends a dropdown caret after the label.
|
|
30
|
+
* @property {boolean} loading - Shows a spinner and blocks interaction.
|
|
31
|
+
* @property {boolean} disabled - Disables the button.
|
|
32
|
+
* @property {'button'|'submit'|'reset'} type - Behaviour when activated. `submit` / `reset` act on
|
|
33
|
+
* the nearest ancestor `<form>`. Ignored when `href` is set. Default `'button'`.
|
|
34
|
+
* @property {string} name - Name submitted with the owning form (button mode only).
|
|
35
|
+
* @property {string} value - Value submitted with the owning form (button mode only).
|
|
36
|
+
* @property {string} href - When set, the button renders as a link to this URL.
|
|
37
|
+
* @property {string} target - Where to open the linked URL (link mode only).
|
|
38
|
+
* @property {string} rel - `rel` attribute for the link (link mode only). Default `'noreferrer noopener'`.
|
|
39
|
+
* @property {string} download - Tells the browser to download the linked URL (link mode only).
|
|
40
|
+
*/
|
|
41
|
+
export default class Button extends TemplateElement {
|
|
42
|
+
constructor() {
|
|
43
|
+
super({ styles: [style], shadowRender: true });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
properties() {
|
|
47
|
+
return {
|
|
48
|
+
variant: 'default',
|
|
49
|
+
size: 'medium',
|
|
50
|
+
outline: false,
|
|
51
|
+
pill: false,
|
|
52
|
+
circle: false,
|
|
53
|
+
caret: false,
|
|
54
|
+
loading: false,
|
|
55
|
+
disabled: false,
|
|
56
|
+
type: 'button',
|
|
57
|
+
name: '',
|
|
58
|
+
value: '',
|
|
59
|
+
href: '',
|
|
60
|
+
target: '',
|
|
61
|
+
rel: 'noreferrer noopener',
|
|
62
|
+
download: '',
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Whether the button renders as a link rather than a native button. */
|
|
67
|
+
get isLink() {
|
|
68
|
+
return !!this.href;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Focuses the underlying control. */
|
|
72
|
+
focus(options) {
|
|
73
|
+
this.$refs.control?.focus(options);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Removes focus from the underlying control. */
|
|
77
|
+
blur() {
|
|
78
|
+
this.$refs.control?.blur();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Simulates a click on the underlying control. */
|
|
82
|
+
click() {
|
|
83
|
+
this.$refs.control?.click();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
events() {
|
|
87
|
+
return {
|
|
88
|
+
'.button': {
|
|
89
|
+
click: (event) => {
|
|
90
|
+
if (this.disabled || this.loading) {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
event.stopImmediatePropagation();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// Shadow DOM swallows the native submit/reset, so drive the nearest form by hand.
|
|
96
|
+
if (!this.isLink && (this.type === 'submit' || this.type === 'reset')) {
|
|
97
|
+
const form = this.closest('form');
|
|
98
|
+
if (form) {
|
|
99
|
+
if (this.type === 'submit') form.requestSubmit();
|
|
100
|
+
else form.reset();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** @private */
|
|
109
|
+
contentTemplate() {
|
|
110
|
+
return html`
|
|
111
|
+
<slot part="prefix" name="prefix"></slot>
|
|
112
|
+
<slot part="label"></slot>
|
|
113
|
+
<slot part="suffix" name="suffix"></slot>
|
|
114
|
+
${this.caret ? html`<span part="caret" class="caret" aria-hidden="true">▾</span>` : ''}
|
|
115
|
+
${this.loading ? html`<span part="spinner" class="spinner" aria-hidden="true"></span>` : ''}
|
|
116
|
+
`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
template() {
|
|
120
|
+
const classes = {
|
|
121
|
+
button: true,
|
|
122
|
+
[`button--${this.variant}`]: true,
|
|
123
|
+
[`button--${this.size}`]: true,
|
|
124
|
+
'button--outline': !!this.outline,
|
|
125
|
+
'button--pill': !!this.pill,
|
|
126
|
+
'button--circle': !!this.circle,
|
|
127
|
+
'button--loading': !!this.loading,
|
|
128
|
+
'button--caret': !!this.caret,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
if (this.isLink) {
|
|
132
|
+
return html`
|
|
133
|
+
<a
|
|
134
|
+
ref="control"
|
|
135
|
+
part="base"
|
|
136
|
+
class="${classMap(classes)}"
|
|
137
|
+
role="button"
|
|
138
|
+
aria-disabled="${this.disabled ? 'true' : 'false'}"
|
|
139
|
+
aria-busy="${this.loading ? 'true' : 'false'}"
|
|
140
|
+
tabindex="${this.disabled ? '-1' : '0'}"
|
|
141
|
+
${spreadAttributes({
|
|
142
|
+
href: this.disabled ? undefined : this.href,
|
|
143
|
+
target: this.target || undefined,
|
|
144
|
+
rel: this.target ? this.rel : undefined,
|
|
145
|
+
download: this.download || undefined,
|
|
146
|
+
})}
|
|
147
|
+
>
|
|
148
|
+
${this.contentTemplate()}
|
|
149
|
+
</a>
|
|
150
|
+
`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return html`
|
|
154
|
+
<button
|
|
155
|
+
ref="control"
|
|
156
|
+
part="base"
|
|
157
|
+
class="${classMap(classes)}"
|
|
158
|
+
type="${this.type}"
|
|
159
|
+
?disabled="${this.disabled}"
|
|
160
|
+
aria-busy="${this.loading ? 'true' : 'false'}"
|
|
161
|
+
${spreadAttributes({
|
|
162
|
+
name: this.name || undefined,
|
|
163
|
+
value: this.value || undefined,
|
|
164
|
+
})}
|
|
165
|
+
>
|
|
166
|
+
${this.contentTemplate()}
|
|
167
|
+
</button>
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function define() {
|
|
173
|
+
defineElement('el-button', Button);
|
|
174
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
`button` is a themeable button. It renders a native `<button>` — or an `<a>` when `href` is set — and decorates it with the library's `--el-*` design tokens. It supports semantic variants, sizes, outline / pill / circle shapes, prefix & suffix icon slots, an optional dropdown caret and a loading spinner. The API is modelled on [Shoelace's `<sl-button>`](https://shoelace.style/components/button).
|
|
4
|
+
|
|
5
|
+
Without a theme imported the button stays close to a plain native control (muted surface, no decoration); import a theme to skin 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/button/define';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<el-button variant="primary">Save changes</el-button>
|
|
23
|
+
|
|
24
|
+
<!-- As a link -->
|
|
25
|
+
<el-button href="/docs" target="_blank">Read the docs</el-button>
|
|
26
|
+
|
|
27
|
+
<!-- With icons in the prefix / suffix slots -->
|
|
28
|
+
<el-button variant="primary">
|
|
29
|
+
<el-svg-use slot="prefix" name="icon-user" spritePath=""></el-svg-use>
|
|
30
|
+
Account
|
|
31
|
+
</el-button>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
> Boolean attributes are passed as strings (`disabled="true"`), matching the rest of the library's form components.
|
|
35
|
+
|
|
36
|
+
## API
|
|
37
|
+
|
|
38
|
+
#### Properties/Attributes
|
|
39
|
+
|
|
40
|
+
| Name | Type | Default | Description |
|
|
41
|
+
| --- | --- | --- | --- |
|
|
42
|
+
| `variant` | `string` | `'default'` | `default`, `primary`, `success`, `neutral`, `warning`, `danger` or `text`. |
|
|
43
|
+
| `size` | `string` | `'medium'` | `small`, `medium` or `large`. |
|
|
44
|
+
| `outline` | `boolean` | `false` | Transparent fill with a colored border. |
|
|
45
|
+
| `pill` | `boolean` | `false` | Fully rounded ends. |
|
|
46
|
+
| `circle` | `boolean` | `false` | Square, fully-rounded icon button (use with a single icon). |
|
|
47
|
+
| `caret` | `boolean` | `false` | Appends a dropdown caret after the label. |
|
|
48
|
+
| `loading` | `boolean` | `false` | Shows a spinner and blocks interaction. |
|
|
49
|
+
| `disabled` | `boolean` | `false` | Disables the button. |
|
|
50
|
+
| `type` | `string` | `'button'` | `button`, `submit` or `reset`. `submit` / `reset` act on the nearest `<form>`. Button-only. |
|
|
51
|
+
| `name` | `string` | `''` | Name submitted with the owning form. Button-only. |
|
|
52
|
+
| `value` | `string` | `''` | Value submitted with the owning form. Button-only. |
|
|
53
|
+
| `href` | `string` | `''` | When set, the button renders as a link to this URL. |
|
|
54
|
+
| `target` | `string` | `''` | Where to open the linked URL. Link-only. |
|
|
55
|
+
| `rel` | `string` | `'noreferrer noopener'` | `rel` for the link (only emitted alongside `target`). Link-only. |
|
|
56
|
+
| `download` | `string` | `''` | Tells the browser to download the linked URL. Link-only. |
|
|
57
|
+
|
|
58
|
+
#### Methods
|
|
59
|
+
|
|
60
|
+
| Name | Description |
|
|
61
|
+
| ----------------- | -------------------------------------------- |
|
|
62
|
+
| `focus(options?)` | Focuses the underlying control. |
|
|
63
|
+
| `blur()` | Removes focus from the underlying control. |
|
|
64
|
+
| `click()` | Simulates a click on the underlying control. |
|
|
65
|
+
|
|
66
|
+
#### Events
|
|
67
|
+
|
|
68
|
+
_None custom — native `click`, `focus` and `blur` behave as usual._
|
|
69
|
+
|
|
70
|
+
#### Slots
|
|
71
|
+
|
|
72
|
+
| Name | Description |
|
|
73
|
+
| ----------- | ------------------------------------------------ |
|
|
74
|
+
| _(default)_ | The button's label. |
|
|
75
|
+
| `prefix` | A presentational prefix icon or similar element. |
|
|
76
|
+
| `suffix` | A presentational suffix icon or similar element. |
|
|
77
|
+
|
|
78
|
+
#### CSS Parts
|
|
79
|
+
|
|
80
|
+
| Name | Description |
|
|
81
|
+
| --------- | --------------------------------------------------- |
|
|
82
|
+
| `base` | The internal `<button>` / `<a>`. |
|
|
83
|
+
| `prefix` | Container wrapping the `prefix` slot. |
|
|
84
|
+
| `label` | The default-slot label wrapper. |
|
|
85
|
+
| `suffix` | Container wrapping the `suffix` slot. |
|
|
86
|
+
| `caret` | The dropdown caret (present only while `caret`). |
|
|
87
|
+
| `spinner` | The loading spinner (present only while `loading`). |
|
|
88
|
+
|
|
89
|
+
#### CSS Custom Properties
|
|
90
|
+
|
|
91
|
+
Reads the standard library design tokens (`--el-color-accent`, `--el-color-bg`, `--el-color-border`, `--el-control-height`, `--el-radius-md`, `--el-space-*`, `--el-font-*`, `--el-focus-ring-*`, …). Skin the button by setting these at the document level via a theme.
|