@webtides/element-library 0.3.1 → 0.5.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 +300 -0
- package/README.md +72 -56
- package/all.js +16 -0
- package/catalog.js +17 -1
- package/custom-elements.json +15912 -10065
- package/package.json +1 -1
- package/src/components/accordion/accordion.changelog.md +11 -0
- package/src/components/accordion/accordion.js +15 -3
- package/src/components/accordion/accordion.readme.md +27 -1
- package/src/components/accordion/accordion.style.js +19 -0
- package/src/components/app-bar/app-bar.changelog.md +24 -0
- package/src/components/app-bar/app-bar.define.js +3 -0
- package/src/components/app-bar/app-bar.js +91 -0
- package/src/components/app-bar/app-bar.readme.md +130 -0
- package/src/components/app-bar/app-bar.style.js +103 -0
- package/src/components/app-frame/app-frame.changelog.md +59 -0
- package/src/components/app-frame/app-frame.define.js +3 -0
- package/src/components/app-frame/app-frame.events.js +6 -0
- package/src/components/app-frame/app-frame.js +1085 -0
- package/src/components/app-frame/app-frame.readme.md +425 -0
- package/src/components/app-frame/app-frame.style.js +534 -0
- package/src/components/button/button.changelog.md +21 -0
- package/src/components/button/button.events.js +3 -0
- package/src/components/button/button.js +145 -3
- package/src/components/button/button.readme.md +72 -4
- package/src/components/button/button.style.js +167 -8
- package/src/components/button-group/button-group.changelog.md +10 -0
- package/src/components/button-group/button-group.readme.md +2 -0
- package/src/components/button-group/button-group.style.js +6 -2
- package/src/components/checkbox-group-field/checkbox-group-field.changelog.md +6 -0
- package/src/components/checkbox-group-field/checkbox-group-field.js +7 -2
- package/src/components/checkbox-group-field/checkbox-group-field.readme.md +23 -1
- package/src/components/combobox-field/combobox-field.changelog.md +6 -0
- package/src/components/combobox-field/combobox-field.readme.md +8 -0
- package/src/components/combobox-field/combobox-field.style.js +2 -0
- package/src/components/date-field/date-field.changelog.md +6 -0
- package/src/components/date-field/date-field.readme.md +10 -0
- package/src/components/date-field/date-field.style.js +8 -3
- package/src/components/description-list/description-list.changelog.md +42 -0
- package/src/components/description-list/description-list.define.js +3 -0
- package/src/components/description-list/description-list.js +49 -0
- package/src/components/description-list/description-list.readme.md +161 -0
- package/src/components/description-list/description-list.style.js +169 -0
- package/src/components/dialog/dialog.changelog.md +7 -0
- package/src/components/dialog/dialog.readme.md +5 -0
- package/src/components/dialog/dialog.style.js +17 -2
- package/src/components/divider/divider.changelog.md +6 -0
- package/src/components/divider/divider.readme.md +1 -1
- package/src/components/divider/divider.style.js +6 -0
- package/src/components/drawer/drawer.changelog.md +7 -0
- package/src/components/drawer/drawer.readme.md +7 -6
- package/src/components/drawer/drawer.style.js +35 -2
- package/src/components/dropdown/dropdown.readme.md +6 -1
- package/src/components/file-field/file-field.changelog.md +8 -0
- package/src/components/file-field/file-field.js +135 -5
- package/src/components/file-field/file-field.readme.md +35 -6
- package/src/components/file-field/file-field.style.js +71 -0
- package/src/components/form-field/form-field.js +1 -1
- package/src/components/input-field/input-field.changelog.md +10 -0
- package/src/components/input-field/input-field.js +192 -14
- package/src/components/input-field/input-field.readme.md +88 -2
- package/src/components/input-field/input-field.style.js +2 -0
- package/src/components/list/list.changelog.md +30 -0
- package/src/components/list/list.define.js +3 -0
- package/src/components/list/list.js +68 -0
- package/src/components/list/list.readme.md +123 -0
- package/src/components/list/list.style.js +56 -0
- package/src/components/list-item/list-item.changelog.md +40 -0
- package/src/components/list-item/list-item.define.js +3 -0
- package/src/components/list-item/list-item.js +130 -0
- package/src/components/list-item/list-item.readme.md +144 -0
- package/src/components/list-item/list-item.style.js +246 -0
- package/src/components/menu/menu.changelog.md +44 -0
- package/src/components/menu/menu.define.js +3 -0
- package/src/components/menu/menu.events.js +5 -0
- package/src/components/menu/menu.js +793 -0
- package/src/components/menu/menu.readme.md +313 -0
- package/src/components/menu/menu.style.js +59 -0
- package/src/components/menu-group/menu-group.changelog.md +20 -0
- package/src/components/menu-group/menu-group.define.js +3 -0
- package/src/components/menu-group/menu-group.js +44 -0
- package/src/components/menu-group/menu-group.readme.md +74 -0
- package/src/components/menu-group/menu-group.style.js +38 -0
- package/src/components/menu-item/menu-item.changelog.md +32 -0
- package/src/components/menu-item/menu-item.define.js +3 -0
- package/src/components/menu-item/menu-item.js +168 -0
- package/src/components/menu-item/menu-item.readme.md +132 -0
- package/src/components/menu-item/menu-item.style.js +117 -0
- package/src/components/nav/nav.changelog.md +35 -0
- package/src/components/nav/nav.define.js +3 -0
- package/src/components/nav/nav.js +212 -0
- package/src/components/nav/nav.readme.md +248 -0
- package/src/components/nav/nav.style.js +269 -0
- package/src/components/nav-item/nav-item.changelog.md +25 -0
- package/src/components/nav-item/nav-item.define.js +3 -0
- package/src/components/nav-item/nav-item.js +75 -0
- package/src/components/nav-item/nav-item.readme.md +111 -0
- package/src/components/nav-item/nav-item.style.js +159 -0
- package/src/components/otp-field/otp-field.changelog.md +6 -0
- package/src/components/otp-field/otp-field.readme.md +8 -0
- package/src/components/otp-field/otp-field.style.js +8 -3
- package/src/components/pagination/pagination.changelog.md +8 -0
- package/src/components/pagination/pagination.js +123 -49
- package/src/components/pagination/pagination.readme.md +24 -6
- package/src/components/pagination/pagination.style.js +11 -1
- package/src/components/password-field/password-field.changelog.md +7 -0
- package/src/components/password-field/password-field.readme.md +11 -1
- package/src/components/password-field/password-field.style.js +2 -0
- package/src/components/popover/popover.changelog.md +6 -0
- package/src/components/popover/popover.style.js +1 -0
- package/src/components/radio-field/radio-field.changelog.md +6 -0
- package/src/components/radio-field/radio-field.js +7 -2
- package/src/components/radio-field/radio-field.readme.md +23 -1
- package/src/components/scroll-to-top/scroll-to-top.changelog.md +7 -5
- package/src/components/scroll-to-top/scroll-to-top.js +16 -12
- package/src/components/scroll-to-top/scroll-to-top.readme.md +2 -0
- package/src/components/segmented-field/segmented-field.changelog.md +27 -0
- package/src/components/segmented-field/segmented-field.define.js +3 -0
- package/src/components/segmented-field/segmented-field.js +175 -0
- package/src/components/segmented-field/segmented-field.readme.md +140 -0
- package/src/components/segmented-field/segmented-field.style.js +193 -0
- package/src/components/splitter/splitter.changelog.md +24 -0
- package/src/components/splitter/splitter.define.js +3 -0
- package/src/components/splitter/splitter.events.js +4 -0
- package/src/components/splitter/splitter.js +237 -0
- package/src/components/splitter/splitter.readme.md +164 -0
- package/src/components/splitter/splitter.style.js +100 -0
- package/src/components/status-bar/status-bar.changelog.md +25 -0
- package/src/components/status-bar/status-bar.define.js +3 -0
- package/src/components/status-bar/status-bar.js +74 -0
- package/src/components/status-bar/status-bar.readme.md +139 -0
- package/src/components/status-bar/status-bar.style.js +122 -0
- package/src/components/tab-group/tab-group.changelog.md +7 -0
- package/src/components/tab-group/tab-group.js +30 -9
- package/src/components/tab-group/tab-group.readme.md +14 -0
- package/src/components/textarea-field/textarea-field.changelog.md +6 -0
- package/src/components/textarea-field/textarea-field.js +14 -1
- package/src/components/textarea-field/textarea-field.readme.md +23 -1
- package/src/components/toast/toast.changelog.md +6 -0
- package/src/components/toast/toast.readme.md +5 -3
- package/src/components/toast/toast.style.js +22 -6
- package/src/components/toolbar/toolbar.changelog.md +24 -0
- package/src/components/toolbar/toolbar.define.js +3 -0
- package/src/components/toolbar/toolbar.js +233 -0
- package/src/components/toolbar/toolbar.readme.md +156 -0
- package/src/components/toolbar/toolbar.style.js +49 -0
- package/src/components/tooltip/tooltip.changelog.md +11 -0
- package/src/components/tooltip/tooltip.js +51 -4
- package/src/components/tooltip/tooltip.readme.md +26 -1
- package/src/components/tree/tree.changelog.md +23 -0
- package/src/components/tree/tree.define.js +3 -0
- package/src/components/tree/tree.js +138 -0
- package/src/components/tree/tree.readme.md +119 -0
- package/src/components/tree/tree.style.js +16 -0
- package/src/components/tree-item/tree-item.changelog.md +23 -0
- package/src/components/tree-item/tree-item.define.js +3 -0
- package/src/components/tree-item/tree-item.events.js +3 -0
- package/src/components/tree-item/tree-item.js +246 -0
- package/src/components/tree-item/tree-item.readme.md +128 -0
- package/src/components/tree-item/tree-item.style.js +226 -0
- package/src/styles/appearance.style.js +47 -0
- package/src/styles/choice-group.style.js +27 -1
- package/src/styles/input-control.style.js +87 -0
- package/src/styles/modal.style.js +14 -1
- package/src/styles/native.css +100 -0
- package/src/styles/size.style.js +41 -0
- package/src/utils/floating.js +15 -1
- package/src/utils/focus.js +69 -0
- package/src/utils/options.js +35 -0
- package/src/utils/scroll.js +24 -0
- package/src/utils/text-entry-attributes.js +13 -0
- package/types/all.d.ts +16 -0
- package/types/src/components/accordion/accordion.d.ts +3 -1
- package/types/src/components/app-bar/app-bar.d.ts +43 -0
- package/types/src/components/app-bar/app-bar.define.d.ts +1 -0
- package/types/src/components/app-bar/app-bar.style.d.ts +2 -0
- package/types/src/components/app-frame/app-frame.d.ts +497 -0
- package/types/src/components/app-frame/app-frame.define.d.ts +1 -0
- package/types/src/components/app-frame/app-frame.events.d.ts +7 -0
- package/types/src/components/app-frame/app-frame.style.d.ts +8 -0
- package/types/src/components/button/button.d.ts +61 -0
- package/types/src/components/button/button.events.d.ts +4 -0
- package/types/src/components/checkbox-group-field/checkbox-group-field.d.ts +5 -2
- package/types/src/components/combobox-field/combobox-field.d.ts +10 -0
- package/types/src/components/date-field/date-field.d.ts +10 -0
- package/types/src/components/description-list/description-list.d.ts +34 -0
- package/types/src/components/description-list/description-list.define.d.ts +1 -0
- package/types/src/components/description-list/description-list.style.d.ts +2 -0
- package/types/src/components/file-field/file-field.d.ts +68 -3
- package/types/src/components/form-field/form-field.d.ts +1 -1
- package/types/src/components/input-field/input-field.d.ts +99 -0
- package/types/src/components/list/list.d.ts +41 -0
- package/types/src/components/list/list.define.d.ts +1 -0
- package/types/src/components/list/list.style.d.ts +2 -0
- package/types/src/components/list-item/list-item.d.ts +64 -0
- package/types/src/components/list-item/list-item.define.d.ts +1 -0
- package/types/src/components/list-item/list-item.style.d.ts +2 -0
- package/types/src/components/menu/menu.d.ts +362 -0
- package/types/src/components/menu/menu.define.d.ts +1 -0
- package/types/src/components/menu/menu.events.d.ts +6 -0
- package/types/src/components/menu/menu.style.d.ts +2 -0
- package/types/src/components/menu-group/menu-group.d.ts +24 -0
- package/types/src/components/menu-group/menu-group.define.d.ts +1 -0
- package/types/src/components/menu-group/menu-group.style.d.ts +2 -0
- package/types/src/components/menu-item/menu-item.d.ts +80 -0
- package/types/src/components/menu-item/menu-item.define.d.ts +1 -0
- package/types/src/components/menu-item/menu-item.style.d.ts +2 -0
- package/types/src/components/nav/nav.d.ts +103 -0
- package/types/src/components/nav/nav.define.d.ts +1 -0
- package/types/src/components/nav/nav.style.d.ts +2 -0
- package/types/src/components/nav-item/nav-item.d.ts +39 -0
- package/types/src/components/nav-item/nav-item.define.d.ts +1 -0
- package/types/src/components/nav-item/nav-item.style.d.ts +2 -0
- package/types/src/components/otp-field/otp-field.d.ts +10 -0
- package/types/src/components/pagination/pagination.d.ts +31 -2
- package/types/src/components/password-field/password-field.d.ts +10 -0
- package/types/src/components/radio-field/radio-field.d.ts +5 -2
- package/types/src/components/scroll-to-top/scroll-to-top.d.ts +6 -5
- package/types/src/components/segmented-field/segmented-field.d.ts +85 -0
- package/types/src/components/segmented-field/segmented-field.define.d.ts +1 -0
- package/types/src/components/segmented-field/segmented-field.style.d.ts +2 -0
- package/types/src/components/splitter/splitter.d.ts +127 -0
- package/types/src/components/splitter/splitter.define.d.ts +1 -0
- package/types/src/components/splitter/splitter.events.d.ts +5 -0
- package/types/src/components/splitter/splitter.style.d.ts +2 -0
- package/types/src/components/status-bar/status-bar.d.ts +44 -0
- package/types/src/components/status-bar/status-bar.define.d.ts +1 -0
- package/types/src/components/status-bar/status-bar.style.d.ts +2 -0
- package/types/src/components/tab-group/tab-group.d.ts +17 -0
- package/types/src/components/textarea-field/textarea-field.d.ts +7 -0
- package/types/src/components/toolbar/toolbar.d.ts +96 -0
- package/types/src/components/toolbar/toolbar.define.d.ts +1 -0
- package/types/src/components/toolbar/toolbar.style.d.ts +2 -0
- package/types/src/components/tooltip/tooltip.d.ts +26 -0
- package/types/src/components/tree/tree.d.ts +62 -0
- package/types/src/components/tree/tree.define.d.ts +1 -0
- package/types/src/components/tree/tree.style.d.ts +2 -0
- package/types/src/components/tree-item/tree-item.d.ts +106 -0
- package/types/src/components/tree-item/tree-item.define.d.ts +1 -0
- package/types/src/components/tree-item/tree-item.events.d.ts +4 -0
- package/types/src/components/tree-item/tree-item.style.d.ts +2 -0
- package/types/src/styles/appearance.style.d.ts +31 -0
- package/types/src/styles/choice-group.style.d.ts +1 -1
- package/types/src/styles/input-control.style.d.ts +15 -0
- package/types/src/styles/modal.style.d.ts +5 -0
- package/types/src/styles/size.style.d.ts +24 -0
- package/types/src/utils/floating.d.ts +11 -0
- package/types/src/utils/focus.d.ts +25 -0
- package/types/src/utils/options.d.ts +17 -0
- package/types/src/utils/scroll.d.ts +11 -0
- package/types/src/utils/text-entry-attributes.d.ts +10 -0
- package/web-types.json +2935 -308
|
@@ -5,16 +5,31 @@ const css = String.raw;
|
|
|
5
5
|
/*
|
|
6
6
|
* What is the dialog's own: a box in the middle of the viewport, which fades in and rises a little.
|
|
7
7
|
* The paint of the surface, the backdrop and the parts are in the modal module.
|
|
8
|
+
*
|
|
9
|
+
* The middle is the one of what the user can see and reach. On a phone the system takes room at
|
|
10
|
+
* the edges of the screen, the notch and the home indicator, where the page reaches under them
|
|
11
|
+
* (viewport-fit=cover): the box keeps out of that room. Elsewhere the room is nothing.
|
|
8
12
|
*/
|
|
9
13
|
const style = css`
|
|
10
14
|
dialog {
|
|
15
|
+
--_el-dialog-top: env(safe-area-inset-top, 0px);
|
|
16
|
+
--_el-dialog-right: env(safe-area-inset-right, 0px);
|
|
17
|
+
--_el-dialog-bottom: env(safe-area-inset-bottom, 0px);
|
|
18
|
+
--_el-dialog-left: env(safe-area-inset-left, 0px);
|
|
19
|
+
|
|
20
|
+
/* The browser centres a modal dialog between the four edges of the viewport. */
|
|
21
|
+
inset: var(--_el-dialog-top) var(--_el-dialog-right) var(--_el-dialog-bottom) var(--_el-dialog-left);
|
|
11
22
|
margin: auto;
|
|
12
23
|
border: var(--el-border-width, 0) solid var(--el-color-border, transparent);
|
|
13
24
|
border-radius: var(--el-radius-lg, 0);
|
|
14
25
|
|
|
15
26
|
width: var(--el-dialog-width, 31rem);
|
|
16
|
-
max-width: calc(100vw - 2 * var(--el-space-4, 1rem));
|
|
17
|
-
|
|
27
|
+
max-width: calc(100vw - 2 * var(--el-space-4, 1rem) - var(--_el-dialog-left) - var(--_el-dialog-right));
|
|
28
|
+
/* Never higher than what the browser shows. 100vh is the height with the address bar of a
|
|
29
|
+
phone taken in: while the bar is there, the footer of a long dialog would be below the
|
|
30
|
+
edge. A browser that does not know the dynamic unit keeps the line before it. */
|
|
31
|
+
max-height: calc(100vh - 2 * var(--el-space-4, 1rem) - var(--_el-dialog-top) - var(--_el-dialog-bottom));
|
|
32
|
+
max-height: calc(100dvh - 2 * var(--el-space-4, 1rem) - var(--_el-dialog-top) - var(--_el-dialog-bottom));
|
|
18
33
|
|
|
19
34
|
opacity: 0;
|
|
20
35
|
transform: translateY(var(--el-dialog-enter-offset, 0.5rem));
|
|
@@ -12,6 +12,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
12
12
|
|
|
13
13
|
## Unreleased
|
|
14
14
|
|
|
15
|
+
## [0.5.0] - 2026-11-27
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- A container can give its lines room: it names the room in a property that inherits (`--_el-context-divider-space`, internal), and the line has it in front of it and after it, above and below a horizontal line and at both sides of a vertical one. `el-menu` does so for a line between two entries. Outside of such a container a divider has no space around it, as before. ([#206](https://github.com/webtides/element-library/issues/206))
|
|
20
|
+
|
|
15
21
|
## [0.3.0] - 2026-11-17
|
|
16
22
|
|
|
17
23
|
### Added
|
|
@@ -66,7 +66,7 @@ _None._
|
|
|
66
66
|
|
|
67
67
|
## Space around the line
|
|
68
68
|
|
|
69
|
-
A divider has no space around it. Where it stands in a layout with a `gap`, the gap is the distance to the content on both sides. Anywhere else, set a margin on the element:
|
|
69
|
+
A divider has no space around it. Where it stands in a layout with a `gap`, the gap is the distance to the content on both sides. In an [`el-menu`](../menu/menu.readme.md) the menu gives it room above and below. Anywhere else, set a margin on the element:
|
|
70
70
|
|
|
71
71
|
```css
|
|
72
72
|
el-divider {
|
|
@@ -22,6 +22,10 @@ const style = css`
|
|
|
22
22
|
width: auto;
|
|
23
23
|
height: 0;
|
|
24
24
|
margin: 0;
|
|
25
|
+
/* A container that gives its lines room, a menu, says how much in a property that
|
|
26
|
+
inherits: the room in front of the line and after it. It is a margin of the line in
|
|
27
|
+
here. Outside of such a container the property is not set, and the line has no room. */
|
|
28
|
+
margin-block: var(--_el-context-divider-space, 0px);
|
|
25
29
|
border: none;
|
|
26
30
|
border-block-start: var(--_el-divider-line);
|
|
27
31
|
color: inherit;
|
|
@@ -42,6 +46,8 @@ const style = css`
|
|
|
42
46
|
/* The line stretches to the height of the host, as a flex item does. */
|
|
43
47
|
:host([orientation='vertical']) .divider {
|
|
44
48
|
height: auto;
|
|
49
|
+
margin-block: 0;
|
|
50
|
+
margin-inline: var(--_el-context-divider-space, 0px);
|
|
45
51
|
border-block-start: none;
|
|
46
52
|
border-inline-start: var(--_el-divider-line);
|
|
47
53
|
}
|
|
@@ -12,6 +12,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
12
12
|
|
|
13
13
|
## Unreleased
|
|
14
14
|
|
|
15
|
+
## [0.4.0] - 2026-11-27
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- On a phone whose page reaches under the notch and the home indicator (`viewport-fit=cover`), the header of a drawer was under the status bar and its footer under the home indicator. The surface still reaches the three edges it lies against, and its header, its body and its footer keep clear of that room now. The size the page gives is the one of what is in the drawer, and the room is on top. Elsewhere nothing changes. ([#183](https://github.com/webtides/element-library/issues/183))
|
|
20
|
+
- What is in a drawer and would keep the edges of the screen clear itself (an `el-app-bar`, an `el-nav`) is told that the surface does so, and adds no room of its own.
|
|
21
|
+
|
|
15
22
|
## [0.3.0] - 2026-11-17
|
|
16
23
|
|
|
17
24
|
### Added
|
|
@@ -134,13 +134,14 @@ On a touch screen (`@media (any-pointer: coarse)`) the close button is at least
|
|
|
134
134
|
|
|
135
135
|
The drawer is never wider or higher than the viewport. On a narrow screen a drawer at the start or the end covers the page, and the close button is the way back.
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
## On a phone
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
Where a page reaches under the notch and the home indicator of a phone (`viewport-fit=cover` in its viewport, or a web app on the home screen), the system takes room at the edges of the screen. The surface of the drawer reaches the three edges it lies against, and its header, its body and its footer keep clear of that room: the header starts below the status bar, the footer ends above the home indicator.
|
|
140
|
+
|
|
141
|
+
- The room is padding of the surface (`::part(base)`), on the edges the drawer lies against and not on the one that faces the page.
|
|
142
|
+
- `--el-drawer-size` is the size of what is in the drawer. The room of the screen is on top of it.
|
|
143
|
+
- What is in a drawer and keeps the edges of the screen clear when it is alone, an [`el-app-bar`](../app-bar/app-bar.readme.md) or an [`el-nav`](../nav/nav.readme.md), is told that the drawer does so, and adds no room of its own.
|
|
144
|
+
- Without `viewport-fit=cover`, and on a desktop, the room is nothing and the drawer is as before.
|
|
144
145
|
|
|
145
146
|
## Opening and closing
|
|
146
147
|
|
|
@@ -10,9 +10,27 @@ const border = 'var(--el-border-width, 0)';
|
|
|
10
10
|
*
|
|
11
11
|
* The first rule is the drawer at the end of the line, which is also what a placement that is none
|
|
12
12
|
* of the four gets. The other placements change what differs.
|
|
13
|
+
*
|
|
14
|
+
* On a phone the system takes room at the edges of the screen, where the page reaches under them
|
|
15
|
+
* (viewport-fit=cover): the notch, the rounded corners, the home indicator. The surface of the
|
|
16
|
+
* drawer reaches the three edges it lies against, and its header, its body and its footer stay
|
|
17
|
+
* clear of that room: it is padding of the surface, which the modal module reads. The size the
|
|
18
|
+
* page gives a drawer is the one of what is in it, and the room is on top. Elsewhere the room is
|
|
19
|
+
* nothing.
|
|
13
20
|
*/
|
|
14
21
|
const style = css`
|
|
15
22
|
dialog {
|
|
23
|
+
/* The room of the system at the edges of the screen, by the direction of the text. */
|
|
24
|
+
--_el-drawer-screen-top: env(safe-area-inset-top, 0px);
|
|
25
|
+
--_el-drawer-screen-bottom: env(safe-area-inset-bottom, 0px);
|
|
26
|
+
--_el-drawer-screen-start: env(safe-area-inset-left, 0px);
|
|
27
|
+
--_el-drawer-screen-end: env(safe-area-inset-right, 0px);
|
|
28
|
+
/* The edges the drawer lies against: all but the one that faces the page. */
|
|
29
|
+
--_el-modal-inset-block-start: var(--_el-drawer-screen-top);
|
|
30
|
+
--_el-modal-inset-block-end: var(--_el-drawer-screen-bottom);
|
|
31
|
+
--_el-modal-inset-inline-start: 0px;
|
|
32
|
+
--_el-modal-inset-inline-end: var(--_el-drawer-screen-end);
|
|
33
|
+
|
|
16
34
|
/* The direction the end of a line is in: 1 for the right, -1 for the left. */
|
|
17
35
|
--_el-drawer-end: 1;
|
|
18
36
|
/* How far the drawer is out of the viewport before it is shown. */
|
|
@@ -28,7 +46,9 @@ const style = css`
|
|
|
28
46
|
margin: 0;
|
|
29
47
|
max-inline-size: 100%;
|
|
30
48
|
max-block-size: 100%;
|
|
31
|
-
inline-size:
|
|
49
|
+
inline-size: calc(
|
|
50
|
+
var(--el-drawer-size, 25rem) + var(--_el-modal-inset-inline-start) + var(--_el-modal-inset-inline-end)
|
|
51
|
+
);
|
|
32
52
|
/* From edge to edge: the browser gives a dialog the height of its content. */
|
|
33
53
|
block-size: auto;
|
|
34
54
|
|
|
@@ -46,9 +66,13 @@ const style = css`
|
|
|
46
66
|
\`:dir(rtl)\` for an element inside the shadow root. */
|
|
47
67
|
:host(:dir(rtl)) dialog {
|
|
48
68
|
--_el-drawer-end: -1;
|
|
69
|
+
--_el-drawer-screen-start: env(safe-area-inset-right, 0px);
|
|
70
|
+
--_el-drawer-screen-end: env(safe-area-inset-left, 0px);
|
|
49
71
|
}
|
|
50
72
|
|
|
51
73
|
:host([placement='start']) dialog {
|
|
74
|
+
--_el-modal-inset-inline-start: var(--_el-drawer-screen-start);
|
|
75
|
+
--_el-modal-inset-inline-end: 0px;
|
|
52
76
|
--_el-drawer-x: calc(-100% * var(--_el-drawer-end));
|
|
53
77
|
inset-inline: 0 auto;
|
|
54
78
|
border-inline-width: 0 ${border};
|
|
@@ -58,14 +82,22 @@ const style = css`
|
|
|
58
82
|
/* Across the viewport, and as high as the content unless a size is given. */
|
|
59
83
|
:host([placement='top']) dialog,
|
|
60
84
|
:host([placement='bottom']) dialog {
|
|
85
|
+
--_el-modal-inset-inline-start: var(--_el-drawer-screen-start);
|
|
86
|
+
--_el-modal-inset-inline-end: var(--_el-drawer-screen-end);
|
|
87
|
+
/* The size of the page and the room of the system on top of it. Without a size the
|
|
88
|
+
property is not valid, and the drawer is as high as its content. */
|
|
89
|
+
--_el-drawer-block-size: calc(
|
|
90
|
+
var(--el-drawer-size) + var(--_el-modal-inset-block-start) + var(--_el-modal-inset-block-end)
|
|
91
|
+
);
|
|
61
92
|
--_el-drawer-x: 0;
|
|
62
93
|
inset-inline: 0;
|
|
63
94
|
inline-size: auto;
|
|
64
|
-
block-size: var(--
|
|
95
|
+
block-size: var(--_el-drawer-block-size, auto);
|
|
65
96
|
border-inline-width: 0;
|
|
66
97
|
}
|
|
67
98
|
|
|
68
99
|
:host([placement='top']) dialog {
|
|
100
|
+
--_el-modal-inset-block-end: 0px;
|
|
69
101
|
--_el-drawer-y: -100%;
|
|
70
102
|
inset-block-end: auto;
|
|
71
103
|
border-block-end-width: ${border};
|
|
@@ -73,6 +105,7 @@ const style = css`
|
|
|
73
105
|
}
|
|
74
106
|
|
|
75
107
|
:host([placement='bottom']) dialog {
|
|
108
|
+
--_el-modal-inset-block-start: 0px;
|
|
76
109
|
--_el-drawer-y: 100%;
|
|
77
110
|
inset-block-start: auto;
|
|
78
111
|
border-block-start-width: ${border};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Dropdown
|
|
2
2
|
|
|
3
|
-
`dropdown` is a component that
|
|
3
|
+
`dropdown` is a component that shows and hides a panel for a trigger, with trigger and content slots. It closes when the user clicks outside or presses the Escape key.
|
|
4
|
+
|
|
5
|
+
The panel is in the flow of the page: it takes room below its trigger, and what follows moves down. That is what the dropdown is for, a part of the page that opens in its place. For the two things it is often taken for, there are elements of their own:
|
|
6
|
+
|
|
7
|
+
- **A menu of actions** behind a button is an [`el-menu`](../menu/menu.readme.md): entries with roles, the keyboard through them, and a panel that floats.
|
|
8
|
+
- **A panel that floats** next to its anchor, with any content, is an [`el-popover`](../popover/popover.readme.md).
|
|
4
9
|
|
|
5
10
|
## How to use
|
|
6
11
|
|
|
@@ -12,6 +12,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
12
12
|
|
|
13
13
|
## Unreleased
|
|
14
14
|
|
|
15
|
+
## [0.5.0] - 2026-11-27
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- `drop-message`: an area to drop a file onto, around the control, with that text in it. The control took a drop on its small button, and nothing invited one. While a dragged file is over the area it looks different, and the host has the state `dragover`. A click on the area opens the dialog; the keyboard is on the control in it. ([#197](https://github.com/webtides/element-library/issues/197))
|
|
20
|
+
- A drop is a choice as one in the dialog: the control has the files, `input` and `change` are fired on it, and `input-change` reports them. A drop that `accept` or `multiple` refuses is not taken, the control keeps what it had, and the field says that the choice was not valid, with its `error-message`. ([#197](https://github.com/webtides/element-library/issues/197))
|
|
21
|
+
- Without JavaScript the area is a box with its text around the control of the browser, which posts the file with its form as before. ([#197](https://github.com/webtides/element-library/issues/197))
|
|
22
|
+
|
|
15
23
|
## [0.3.0] - 2026-11-17
|
|
16
24
|
|
|
17
25
|
### Added
|
|
@@ -10,15 +10,21 @@ import style from './file-field.style.js';
|
|
|
10
10
|
* The files come from the user. A script cannot choose one, the browser does not allow that; it can
|
|
11
11
|
* take the choice away with an empty `value`.
|
|
12
12
|
*
|
|
13
|
+
* With `drop-message` the field shows an area around its control to drop a file onto, with that
|
|
14
|
+
* text in it. The area looks different while a dragged file is over it, a click on it opens the
|
|
15
|
+
* dialog, and a drop is a choice as one in the dialog is: the control has the files, and the same
|
|
16
|
+
* events are fired.
|
|
17
|
+
*
|
|
13
18
|
* @element el-file-field
|
|
14
19
|
*
|
|
15
|
-
* @fires {CustomEvent<string[]>} input-change - Fired when the user has chosen files,
|
|
16
|
-
* choice was taken away. `detail` is the list of the names;
|
|
17
|
-
* element. Bubbles.
|
|
20
|
+
* @fires {CustomEvent<string[]>} input-change - Fired when the user has chosen files, in the
|
|
21
|
+
* dialog or with a drop, and when the choice was taken away. `detail` is the list of the names;
|
|
22
|
+
* the files are in `files` of the element. Bubbles.
|
|
18
23
|
*
|
|
19
24
|
* @cssstate touched - Set on the host once the user has left the control for another place of the
|
|
20
25
|
* page, or the browser has refused a submit because of it. Inherits `valid` and `invalid` from
|
|
21
26
|
* `FormField`.
|
|
27
|
+
* @cssstate dragover - Set on the host while a dragged file is over the area to drop onto.
|
|
22
28
|
*
|
|
23
29
|
* @property {string[]} value - The names of the chosen files. It follows the control: a script can
|
|
24
30
|
* set it to an empty list, which takes the choice away, and to nothing else.
|
|
@@ -31,8 +37,17 @@ import style from './file-field.style.js';
|
|
|
31
37
|
* @property {'small'|'medium'|'large'} size - Size of the control: its height, its padding and its
|
|
32
38
|
* font size. Default `'medium'`. Reflected to the `size` attribute. It shows once the control is
|
|
33
39
|
* decorated (`styles/native.css`); a control with the look of the browser keeps its size.
|
|
40
|
+
* @property {string} dropMessage - The text of an area to drop a file onto: "Drop the list here,
|
|
41
|
+
* or choose it". With one the field shows the area, around its control. Default `''`.
|
|
34
42
|
*/
|
|
35
43
|
export default class FileField extends FormField {
|
|
44
|
+
/**
|
|
45
|
+
* How many elements of the area a dragged file is over: the browser tells of every one it
|
|
46
|
+
* enters and leaves, the text and the control in the area as well.
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
_dragDepth = 0;
|
|
50
|
+
|
|
36
51
|
/**
|
|
37
52
|
* The names the control had when the field last looked. See `_matchControl()`.
|
|
38
53
|
* @private
|
|
@@ -64,6 +79,7 @@ export default class FileField extends FormField {
|
|
|
64
79
|
multiple: false,
|
|
65
80
|
capture: null,
|
|
66
81
|
size: 'medium',
|
|
82
|
+
dropMessage: '',
|
|
67
83
|
};
|
|
68
84
|
}
|
|
69
85
|
|
|
@@ -108,9 +124,88 @@ export default class FileField extends FormField {
|
|
|
108
124
|
blur: () => document.hasFocus() && this.onBlur(),
|
|
109
125
|
invalid: (event) => this._onInvalid(event.target),
|
|
110
126
|
},
|
|
127
|
+
'.drop-area': {
|
|
128
|
+
click: (event) => this._onAreaClick(event),
|
|
129
|
+
dragenter: (event) => this._onDrag(event, 1),
|
|
130
|
+
dragover: (event) => this._onDrag(event, 0),
|
|
131
|
+
dragleave: (event) => this._onDrag(event, -1),
|
|
132
|
+
drop: (event) => this._onDrop(event),
|
|
133
|
+
},
|
|
111
134
|
};
|
|
112
135
|
}
|
|
113
136
|
|
|
137
|
+
/**
|
|
138
|
+
* A click on the area beside its control opens the dialog, as a click on the control does.
|
|
139
|
+
* @private
|
|
140
|
+
* @param {MouseEvent} event
|
|
141
|
+
*/
|
|
142
|
+
_onAreaClick(event) {
|
|
143
|
+
const control = this.$refs.input;
|
|
144
|
+
if (event.target === control || control.disabled) return;
|
|
145
|
+
control.click();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* A file is dragged into the area, over it or out of it. The area says that it takes the file
|
|
150
|
+
* (the browser shows a drop that is allowed with the pointer), and the host has the state
|
|
151
|
+
* `dragover` for as long. Text or a link that is dragged is nothing for this field.
|
|
152
|
+
* @private
|
|
153
|
+
* @param {DragEvent} event
|
|
154
|
+
* @param {-1 | 0 | 1} step - Into an element of the area, over one, or out of one.
|
|
155
|
+
*/
|
|
156
|
+
_onDrag(event, step) {
|
|
157
|
+
if (this.$refs.input.disabled || !event.dataTransfer?.types?.includes('Files')) return;
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
160
|
+
|
|
161
|
+
this._dragDepth = Math.max(0, this._dragDepth + step);
|
|
162
|
+
if (this._dragDepth > 0 || step === 0) this._internals.states.add('dragover');
|
|
163
|
+
else this._internals.states.delete('dragover');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Files were dropped onto the area. They are a choice as one in the dialog is: the control
|
|
168
|
+
* gets them and tells of it with `input` and `change`, which the field follows as it does for
|
|
169
|
+
* the dialog.
|
|
170
|
+
*
|
|
171
|
+
* The dialog does not offer what `accept` leaves out, and one file alone without `multiple`.
|
|
172
|
+
* A drop can bring anything, so the field asks itself. A drop it cannot take as a whole is
|
|
173
|
+
* not taken at all: the control keeps what it had, and the field says that the choice was
|
|
174
|
+
* not valid, with its error message.
|
|
175
|
+
* @private
|
|
176
|
+
* @param {DragEvent} event
|
|
177
|
+
*/
|
|
178
|
+
_onDrop(event) {
|
|
179
|
+
const control = this.$refs.input;
|
|
180
|
+
if (control.disabled || !event.dataTransfer?.types?.includes('Files')) return;
|
|
181
|
+
// The browser would open the file in place of the page.
|
|
182
|
+
event.preventDefault();
|
|
183
|
+
this._dragDepth = 0;
|
|
184
|
+
this._internals.states.delete('dragover');
|
|
185
|
+
|
|
186
|
+
const files = [...event.dataTransfer.files];
|
|
187
|
+
if (files.length === 0) return;
|
|
188
|
+
if ((files.length > 1 && !this.multiple) || !files.every((file) => accepts(this.accept, file))) {
|
|
189
|
+
this.touched = true;
|
|
190
|
+
this.valid = false;
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
control.files = event.dataTransfer.files;
|
|
195
|
+
control.dispatchEvent(new Event('input', { bubbles: true }));
|
|
196
|
+
control.dispatchEvent(new Event('change', { bubbles: true }));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* The description of the control: the text of the area first, then the messages of the field.
|
|
201
|
+
* @private
|
|
202
|
+
* @returns {string}
|
|
203
|
+
*/
|
|
204
|
+
_describedBy() {
|
|
205
|
+
const ids = super._describedBy();
|
|
206
|
+
return this.dropMessage ? `${this._idOf('drop-message')} ${ids}` : ids;
|
|
207
|
+
}
|
|
208
|
+
|
|
114
209
|
/**
|
|
115
210
|
* The user has chosen files, or has taken the choice away in the dialog.
|
|
116
211
|
* @returns {void}
|
|
@@ -180,8 +275,7 @@ export default class FileField extends FormField {
|
|
|
180
275
|
/** @private */
|
|
181
276
|
fieldTemplate() {
|
|
182
277
|
const capture = this.capture ?? false;
|
|
183
|
-
|
|
184
|
-
return html`
|
|
278
|
+
const control = html`
|
|
185
279
|
<input
|
|
186
280
|
ref="input"
|
|
187
281
|
type="file"
|
|
@@ -197,9 +291,45 @@ export default class FileField extends FormField {
|
|
|
197
291
|
aria-errormessage="${this._idOf('error-message')}"
|
|
198
292
|
/>
|
|
199
293
|
`;
|
|
294
|
+
|
|
295
|
+
// A field without an area is its control, as it was.
|
|
296
|
+
if (!this.dropMessage) return control;
|
|
297
|
+
|
|
298
|
+
// The control is in the area and stays the control of the browser: it shows the name of
|
|
299
|
+
// the file, takes the keyboard, and posts the file where no script runs.
|
|
300
|
+
return html`
|
|
301
|
+
<div class="drop-area">
|
|
302
|
+
<span id="${this._idOf('drop-message')}" class="drop-message">${this.dropMessage}</span>
|
|
303
|
+
${control}
|
|
304
|
+
</div>
|
|
305
|
+
`;
|
|
200
306
|
}
|
|
201
307
|
}
|
|
202
308
|
|
|
309
|
+
/**
|
|
310
|
+
* Whether a file is one of the kinds an `accept` attribute names: an ending (`.pdf`), a type
|
|
311
|
+
* (`application/pdf`) or a group of types (`image/*`), with commas between them. Without one
|
|
312
|
+
* every file is.
|
|
313
|
+
* @param {string} accept
|
|
314
|
+
* @param {File} file
|
|
315
|
+
* @returns {boolean}
|
|
316
|
+
*/
|
|
317
|
+
export function accepts(accept, file) {
|
|
318
|
+
const kinds = String(accept ?? '')
|
|
319
|
+
.split(',')
|
|
320
|
+
.map((kind) => kind.trim().toLowerCase())
|
|
321
|
+
.filter(Boolean);
|
|
322
|
+
if (kinds.length === 0) return true;
|
|
323
|
+
|
|
324
|
+
const name = file.name.toLowerCase();
|
|
325
|
+
const type = file.type.toLowerCase();
|
|
326
|
+
return kinds.some((kind) => {
|
|
327
|
+
if (kind.startsWith('.')) return name.endsWith(kind);
|
|
328
|
+
if (kind.endsWith('/*')) return type.startsWith(kind.slice(0, -1));
|
|
329
|
+
return type === kind;
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
203
333
|
export function define() {
|
|
204
334
|
defineElement('el-file-field', FileField);
|
|
205
335
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# FileField
|
|
2
2
|
|
|
3
|
-
`file-field` takes one or several files for a form: a CV, a receipt, a picture. It renders a native `<input type="file">`, so the dialog of the system,
|
|
3
|
+
`file-field` takes one or several files for a form: a CV, a receipt, a picture. It renders a native `<input type="file">`, so the dialog of the system, the keyboard and the form submission are the ones of the browser. With `drop-message` it shows an area to drop a file onto. It extends `form-field`, inheriting the label, help text, error message, `required` and touched-state handling.
|
|
4
4
|
|
|
5
5
|
It is headless by default: the control keeps the look of the browser. `styles/native.css` gives it the border of the other fields and its button the tokens of the theme.
|
|
6
6
|
|
|
@@ -43,6 +43,31 @@ The files come from the user. A script cannot choose one, the browser does not a
|
|
|
43
43
|
field.value = [];
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
+
#### An area to drop a file onto
|
|
47
|
+
|
|
48
|
+
The control of the browser takes a drop, on its small button, and nothing invites one. With `drop-message` the field shows an area around the control, with that text in it:
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<el-file-field
|
|
52
|
+
name="list"
|
|
53
|
+
label="Your list"
|
|
54
|
+
accept=".opml,.csv"
|
|
55
|
+
drop-message="Drop the list here, or choose it"
|
|
56
|
+
error-message="An OPML or a CSV file"
|
|
57
|
+
></el-file-field>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- **While a file is dragged over the area** it looks different: a line that is drawn through in the accent colour, and a tint of it. The host has the state `dragover` for a look of the page (`el-file-field:state(dragover)`).
|
|
61
|
+
- **A drop is a choice**, as one in the dialog: the control has the files, `input` and `change` are fired on it, and the field reports them with `input-change`. A page that reads the file on a change needs no second path.
|
|
62
|
+
- **A click on the area** opens the dialog. The keyboard is on the control in the area, which the Tab key stops at: `Enter` and `Space` open the dialog, and the ring of the focus is around the area.
|
|
63
|
+
- **What the field does not take.** The dialog offers only what `accept` names, and one file without `multiple`. A drop can bring anything, so the field asks itself: a file whose ending or type `accept` does not name, or more than one file for a field that takes one. Such a drop is not taken at all, also where some of its files would do. The control keeps what it had, and the field says that the choice was not valid: `valid` is `false` and the `error-message` shows, until the next choice.
|
|
64
|
+
- **Only files.** A text or a link that is dragged over the area is nothing for the field.
|
|
65
|
+
- **The text describes the control** for assistive technology (`aria-describedby`), in front of the help message.
|
|
66
|
+
- **Without JavaScript** the area is a box with its text around the control of the browser, which posts the file with its form as before. The script adds the drop and the click.
|
|
67
|
+
- **A field that is disabled** takes no drop and opens no dialog, and the area fades.
|
|
68
|
+
|
|
69
|
+
Not in the field: the progress of an upload, and previews of the chosen files.
|
|
70
|
+
|
|
46
71
|
#### Checks of the page
|
|
47
72
|
|
|
48
73
|
The browser knows `required` and nothing else about a file: `accept` only says what the dialog offers. The size, the number and the kind of the files are checked by the page. It renders the field as not valid, with the reason as the error message:
|
|
@@ -70,20 +95,22 @@ Inherits all of `form-field`'s properties (`name`, `value`, `required`, `disable
|
|
|
70
95
|
| `multiple` | `boolean` | `false` | Whether more than one file can be chosen. |
|
|
71
96
|
| `capture` | `string \| null` | `null` | A phone takes the picture or the recording with its camera (`user`, `environment`) and does not open its files. |
|
|
72
97
|
| `size` | `'small' \| 'medium' \| 'large'` | `'medium'` | Size of the control. Reflected to the `size` attribute. It shows once the control is decorated. |
|
|
98
|
+
| `dropMessage` | `string` | `''` | The text of an area to drop a file onto. With one the field shows the area, around its control. |
|
|
73
99
|
|
|
74
100
|
#### Events
|
|
75
101
|
|
|
76
102
|
| Name | Detail | Description |
|
|
77
103
|
| --- | --- | --- |
|
|
78
|
-
| `input-change` | `string[]` (the value) | Fired when the user has chosen files, also ones with the names of the files before, and when the choice was taken away. |
|
|
104
|
+
| `input-change` | `string[]` (the value) | Fired when the user has chosen files, in the dialog or with a drop, also ones with the names of the files before, and when the choice was taken away. |
|
|
79
105
|
|
|
80
106
|
#### CSS States
|
|
81
107
|
|
|
82
|
-
| Name
|
|
83
|
-
|
|
|
108
|
+
| Name | Description |
|
|
109
|
+
| --- | --- |
|
|
84
110
|
| `touched` | Set once the user has left the control for another place of the page. The dialog does not set it. |
|
|
85
|
-
| `valid`
|
|
86
|
-
| `invalid` | Set while the field fails validation (`required` with no file, or the page says so with `valid`). |
|
|
111
|
+
| `valid` | Set while the field passes validation. |
|
|
112
|
+
| `invalid` | Set while the field fails validation (`required` with no file, a drop the field did not take, or the page says so with `valid`). |
|
|
113
|
+
| `dragover` | Set while a dragged file is over the area to drop onto. |
|
|
87
114
|
|
|
88
115
|
#### CSS Custom Properties
|
|
89
116
|
|
|
@@ -93,6 +120,8 @@ With `styles/native.css` the control has the border, the radius, the colours and
|
|
|
93
120
|
|
|
94
121
|
The label, the help message, the control and the error message stack in a column, and the texts have one look in every field: see [Layout](../form-field/form-field.readme.md#layout) in the readme of `form-field`.
|
|
95
122
|
|
|
123
|
+
The area to drop onto is no control of the browser, so it has its look without `styles/native.css`: a dashed line from `--el-color-border` and `--el-border-width` (the colour of the text without a theme), `--el-radius-md`, `--el-space-4` of padding, its text in `--el-color-fg-muted`, and `--el-color-accent` while a file is over it. In the area the control has no border of its own.
|
|
124
|
+
|
|
96
125
|
On a touch screen (`@media (any-pointer: coarse)`) the control is at least `--el-touch-target` high. Without that token, and on a fine pointer, the size stays as it is.
|
|
97
126
|
|
|
98
127
|
## Accessibility
|
|
@@ -7,9 +7,80 @@ const css = String.raw;
|
|
|
7
7
|
/**
|
|
8
8
|
* The control keeps the look of the browser, as the control of every field does: `styles/native.css`
|
|
9
9
|
* gives it the border of the other fields and its button the tokens of the theme.
|
|
10
|
+
*
|
|
11
|
+
* The area to drop a file onto is no control of the browser, so its look is here: a dashed line
|
|
12
|
+
* around its text and the control, with the colours of the text where there is no theme. In the
|
|
13
|
+
* area the control has no border of its own, with and without `styles/native.css`: the area is
|
|
14
|
+
* the box. The rules for the control in the area name the area, so they win over the rules for
|
|
15
|
+
* the control of that file whichever comes first.
|
|
10
16
|
*/
|
|
11
17
|
const style = css`
|
|
12
18
|
el-file-field {
|
|
19
|
+
.drop-area {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex: 1 1 auto;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: var(--el-space-2, 8px);
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
min-inline-size: 0;
|
|
27
|
+
padding: var(--el-space-4, 16px);
|
|
28
|
+
border: var(--el-border-width, 1px) dashed var(--el-color-border, currentColor);
|
|
29
|
+
border-radius: var(--el-radius-md, 0);
|
|
30
|
+
background: var(--el-color-bg, transparent);
|
|
31
|
+
color: var(--el-color-fg-muted, inherit);
|
|
32
|
+
text-align: center;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
transition:
|
|
35
|
+
border-color var(--el-duration-md, 0s) var(--el-ease, linear),
|
|
36
|
+
background-color var(--el-duration-md, 0s) var(--el-ease, linear);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.drop-area input {
|
|
40
|
+
inline-size: auto;
|
|
41
|
+
max-inline-size: 100%;
|
|
42
|
+
min-block-size: 0;
|
|
43
|
+
border: 0;
|
|
44
|
+
padding: 0;
|
|
45
|
+
background: transparent;
|
|
46
|
+
box-shadow: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* The ring of the keyboard is around the area, for the control that is in it. */
|
|
50
|
+
.drop-area input:focus {
|
|
51
|
+
outline: none;
|
|
52
|
+
box-shadow: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.drop-area:has(input:focus-visible) {
|
|
56
|
+
outline: var(--el-focus-ring-width, 2px) solid var(--el-color-focus-ring, currentColor);
|
|
57
|
+
outline-offset: var(--el-focus-ring-offset, 2px);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* A file is over the area: a line that is drawn through, in the accent colour, and a tint
|
|
61
|
+
of it. The line is what shows where the user forces colours. */
|
|
62
|
+
&:state(dragover) .drop-area {
|
|
63
|
+
border-style: solid;
|
|
64
|
+
border-color: var(--el-color-accent, currentColor);
|
|
65
|
+
background: color-mix(in srgb, var(--el-color-accent, currentColor) 8%, var(--el-color-bg, transparent));
|
|
66
|
+
color: var(--el-color-fg, inherit);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&:state(invalid) .drop-area {
|
|
70
|
+
border-color: var(--el-color-danger, currentColor);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* A field that is disabled takes no file: the area fades as a control does, and its
|
|
74
|
+
control not a second time. */
|
|
75
|
+
.drop-area:has(input:disabled) {
|
|
76
|
+
opacity: 0.55;
|
|
77
|
+
cursor: not-allowed;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.drop-area input:disabled {
|
|
81
|
+
opacity: 1;
|
|
82
|
+
}
|
|
83
|
+
|
|
13
84
|
/* Touch screens: the control is at least --el-touch-target high, whatever the size of the
|
|
14
85
|
field. Without the token the size stays as it is. */
|
|
15
86
|
@media (any-pointer: coarse) {
|
|
@@ -320,7 +320,7 @@ export default class FormField extends TemplateElement {
|
|
|
320
320
|
* The id is another one on every page load. Server-rendered markup has the ids of the server
|
|
321
321
|
* until the element starts, which writes its own to the same elements.
|
|
322
322
|
* @private
|
|
323
|
-
* @param {'input' | 'help-message' | 'error-message' | 'list'} part
|
|
323
|
+
* @param {'input' | 'help-message' | 'error-message' | 'list' | 'control-start' | 'control-end' | 'drop-message'} part
|
|
324
324
|
* @returns {string}
|
|
325
325
|
*/
|
|
326
326
|
_idOf(part) {
|
|
@@ -12,6 +12,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
12
12
|
|
|
13
13
|
## Unreleased
|
|
14
14
|
|
|
15
|
+
## [0.5.0] - 2026-11-27
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Content of the page at the start and at the end of the control: an element with `slot="start"` or `slot="end"` among the children of the field is taken into the control when the field renders. An icon, a unit, the start of an address, a button. It stands in a row with the input, whose text does not run under it, and follows the reading direction. The field moves the element of the page and does not copy it, and server-rendered markup has it in its place. ([#168](https://github.com/webtides/element-library/issues/168))
|
|
20
|
+
- A click on a text or on an icon in the control puts the focus into the input; a button or a link there keeps its click and its stop of the Tab key. A text there is part of the description of the input (`aria-describedby`), so a unit is read with it; an icon and a button are not. ([#168](https://github.com/webtides/element-library/issues/168))
|
|
21
|
+
- `clearable`: a button at the end of the control that empties the field. It shows while the field has a value and is not disabled, `input-change` reports the empty value, and the focus stays in the input. `clear-label` is its name (`Clear`). ([#168](https://github.com/webtides/element-library/issues/168))
|
|
22
|
+
- With `styles/native.css` the control with its content is the control to the eye: the border, the surface and the focus ring are around all of it, as the border of a field that is not valid and the look of a disabled one, and it is as high as an input of its size alone. Without that file the content stands beside an input with the look of the browser. A field without content and without `clearable` renders its input alone, as before. ([#168](https://github.com/webtides/element-library/issues/168))
|
|
23
|
+
- `maxlength` and `minlength` are passed on to the native `<input>`, in server-rendered markup as well, and one that is not set is not rendered. The control takes no more characters than `maxlength` while the user types, and a typed text that is shorter than `minlength` makes the field invalid the way `required` and `pattern` do, with its `error-message`. Set on the element they did nothing before. The fields that extend this one take both as well. ([#190](https://github.com/webtides/element-library/issues/190))
|
|
24
|
+
|
|
15
25
|
## [0.3.0] - 2026-11-17
|
|
16
26
|
|
|
17
27
|
### Added
|