@f-ewald/components 1.43.0 → 1.45.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/README.md +1 -0
- package/custom-elements.json +288 -2
- package/dist/autocomplete-input.d.ts +7 -2
- package/dist/autocomplete-input.d.ts.map +1 -1
- package/dist/autocomplete-input.js +36 -4
- package/dist/autocomplete-input.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/pixel-fire.d.ts +69 -0
- package/dist/pixel-fire.d.ts.map +1 -0
- package/dist/pixel-fire.js +296 -0
- package/dist/pixel-fire.js.map +1 -0
- package/docs/autocomplete-input.md +6 -2
- package/docs/design-language.md +3 -3
- package/docs/pixel-fire.md +51 -0
- package/llms.txt +36 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,6 +107,7 @@ import "@f-ewald/components/roman-numeral.js";
|
|
|
107
107
|
| `<pagination-nav>` | [API reference](https://f-ewald.github.io/components/docs/pagination-nav.html) |
|
|
108
108
|
| `<percent-bar-chart>` | [API reference](https://f-ewald.github.io/components/docs/percent-bar-chart.html) |
|
|
109
109
|
| `<photo-gallery>` | [API reference](https://f-ewald.github.io/components/docs/photo-gallery.html) |
|
|
110
|
+
| `<pixel-fire>` | [API reference](https://f-ewald.github.io/components/docs/pixel-fire.html) |
|
|
110
111
|
| `<popover-panel>` | [API reference](https://f-ewald.github.io/components/docs/popover-panel.html) |
|
|
111
112
|
| `<price-history-chart>` | [API reference](https://f-ewald.github.io/components/docs/price-history-chart.html) |
|
|
112
113
|
| `<progress-bar>` | [API reference](https://f-ewald.github.io/components/docs/progress-bar.html) |
|
package/custom-elements.json
CHANGED
|
@@ -1917,7 +1917,7 @@
|
|
|
1917
1917
|
"declarations": [
|
|
1918
1918
|
{
|
|
1919
1919
|
"kind": "class",
|
|
1920
|
-
"description": "Generic form-associated text input with a suggestion dropdown, for any\n\"type to filter a list of `{key, value}` options\" use case. Works as a\ndrop-in replacement for a plain `<input>` inside a `<form>`: set `name` on\nthe element itself and consumers keep reading\n`new FormData(form).get(name)` and calling `form.reset()` unchanged — the\nsubmitted value is the picked option's `value`, while `key` is available\nvia the `option-select` event and the `selectedOption` getter for cases\nthat need the underlying id rather than the display text.\n\nSupports two suggestion sources:\n- **API**: set `endpoint` to a URL that, given a `?<query-param>=<text>`\n query string, responds with a JSON array of `{key, value}` objects.\n Requests are debounced as the user types.\n- **Local array**: set `options` to a fixed `AutocompleteOption[]` and the\n component filters it client-side instead of making any network\n request. Useful for small/fixed lists, offline use, or tests. Takes\n priority over `endpoint` whenever it's non-null.\n\nEach option may also carry a pre-rendered `icon` (shown before the value)\nand a `description` (a smaller, muted line under the value); options\nwithout them render as a plain value.\n\nSet `clearable` to show an in-field clear action whenever a value is\npresent.",
|
|
1920
|
+
"description": "Generic form-associated text input with a suggestion dropdown, for any\n\"type to filter a list of `{key, value}` options\" use case. Works as a\ndrop-in replacement for a plain `<input>` inside a `<form>`: set `name` on\nthe element itself and consumers keep reading\n`new FormData(form).get(name)` and calling `form.reset()` unchanged — the\nsubmitted value is the picked option's `value`, while `key` is available\nvia the `option-select` event and the `selectedOption` getter for cases\nthat need the underlying id rather than the display text.\n\nSupports two suggestion sources:\n- **API**: set `endpoint` to a URL that, given a `?<query-param>=<text>`\n query string, responds with a JSON array of `{key, value}` objects.\n Requests are debounced as the user types.\n- **Local array**: set `options` to a fixed `AutocompleteOption[]` and the\n component filters it client-side instead of making any network\n request. Useful for small/fixed lists, offline use, or tests. Takes\n priority over `endpoint` whenever it's non-null.\n\nEach option may also carry a pre-rendered `icon` (shown before the value)\nand a `description` (a smaller, muted line under the value); options\nwithout them render as a plain value. The selected option's icon also\nshows inside the field until the text is edited. Picking an option sets\n`selectedKey`; set `selectedKey` and `value` together to show a selection\nmade elsewhere.\n\nSet `clearable` to show an in-field clear action whenever a value is\npresent.",
|
|
1921
1921
|
"name": "AutocompleteInput",
|
|
1922
1922
|
"members": [
|
|
1923
1923
|
{
|
|
@@ -2030,6 +2030,16 @@
|
|
|
2030
2030
|
"default": "null",
|
|
2031
2031
|
"description": "Fixed candidate list to filter locally instead of fetching from\n`endpoint`. When set (non-null), no network request is ever made —\nthis takes priority over the API mode."
|
|
2032
2032
|
},
|
|
2033
|
+
{
|
|
2034
|
+
"kind": "field",
|
|
2035
|
+
"name": "selectedKey",
|
|
2036
|
+
"type": {
|
|
2037
|
+
"text": "string | null"
|
|
2038
|
+
},
|
|
2039
|
+
"default": "null",
|
|
2040
|
+
"description": "Key of the selected option: set by picking one, or by the caller together with `value`.",
|
|
2041
|
+
"attribute": "selected-key"
|
|
2042
|
+
},
|
|
2033
2043
|
{
|
|
2034
2044
|
"kind": "field",
|
|
2035
2045
|
"name": "_suggestions",
|
|
@@ -2172,7 +2182,7 @@
|
|
|
2172
2182
|
"type": {
|
|
2173
2183
|
"text": "AutocompleteOption | null"
|
|
2174
2184
|
},
|
|
2175
|
-
"description": "
|
|
2185
|
+
"description": "Selected option (picked, or matching `selectedKey`), or null once the input diverges from it.",
|
|
2176
2186
|
"readonly": true
|
|
2177
2187
|
},
|
|
2178
2188
|
{
|
|
@@ -2525,6 +2535,15 @@
|
|
|
2525
2535
|
"default": "3",
|
|
2526
2536
|
"description": "Minimum query length before suggestions are shown.",
|
|
2527
2537
|
"fieldName": "minLength"
|
|
2538
|
+
},
|
|
2539
|
+
{
|
|
2540
|
+
"name": "selected-key",
|
|
2541
|
+
"type": {
|
|
2542
|
+
"text": "string | null"
|
|
2543
|
+
},
|
|
2544
|
+
"default": "null",
|
|
2545
|
+
"description": "Key of the selected option: set by picking one, or by the caller together with `value`.",
|
|
2546
|
+
"fieldName": "selectedKey"
|
|
2528
2547
|
}
|
|
2529
2548
|
],
|
|
2530
2549
|
"superclass": {
|
|
@@ -12371,6 +12390,14 @@
|
|
|
12371
12390
|
"module": "./tree-view.js"
|
|
12372
12391
|
}
|
|
12373
12392
|
},
|
|
12393
|
+
{
|
|
12394
|
+
"kind": "js",
|
|
12395
|
+
"name": "PixelFire",
|
|
12396
|
+
"declaration": {
|
|
12397
|
+
"name": "PixelFire",
|
|
12398
|
+
"module": "./pixel-fire.js"
|
|
12399
|
+
}
|
|
12400
|
+
},
|
|
12374
12401
|
{
|
|
12375
12402
|
"kind": "js",
|
|
12376
12403
|
"name": "PopoverPanel",
|
|
@@ -17865,6 +17892,265 @@
|
|
|
17865
17892
|
}
|
|
17866
17893
|
]
|
|
17867
17894
|
},
|
|
17895
|
+
{
|
|
17896
|
+
"kind": "javascript-module",
|
|
17897
|
+
"path": "src/pixel-fire.ts",
|
|
17898
|
+
"declarations": [
|
|
17899
|
+
{
|
|
17900
|
+
"kind": "class",
|
|
17901
|
+
"description": "Pixelated, 8-bit style fire in the manner of old computer games. By default\nit is pinned full width to the bottom of the viewport as a decorative,\nclick-through overlay; `contained` pins it to the bottom of the nearest\npositioned ancestor instead.\n\nThe strip's height is set with `--pixel-fire-height` (default `8rem`). It\npaints at `z-index: 30`, above ordinary page content but below `app-shell`'s\nchrome and every dialog or popover. Under `prefers-reduced-motion: reduce`\nit draws one still frame instead of animating. The canvas is hidden from\nassistive technology.",
|
|
17902
|
+
"name": "PixelFire",
|
|
17903
|
+
"members": [
|
|
17904
|
+
{
|
|
17905
|
+
"kind": "field",
|
|
17906
|
+
"name": "pixelSize",
|
|
17907
|
+
"type": {
|
|
17908
|
+
"text": "number"
|
|
17909
|
+
},
|
|
17910
|
+
"default": "4",
|
|
17911
|
+
"description": "Size of one fire pixel in CSS pixels; larger values look chunkier.",
|
|
17912
|
+
"attribute": "pixel-size"
|
|
17913
|
+
},
|
|
17914
|
+
{
|
|
17915
|
+
"kind": "field",
|
|
17916
|
+
"name": "intensity",
|
|
17917
|
+
"type": {
|
|
17918
|
+
"text": "number"
|
|
17919
|
+
},
|
|
17920
|
+
"default": "1",
|
|
17921
|
+
"description": "Heat of the fire's source, from `0` to `1`. Lowering it shortens the\nflames; `0` lets the fire burn out.",
|
|
17922
|
+
"attribute": "intensity"
|
|
17923
|
+
},
|
|
17924
|
+
{
|
|
17925
|
+
"kind": "field",
|
|
17926
|
+
"name": "contained",
|
|
17927
|
+
"type": {
|
|
17928
|
+
"text": "boolean"
|
|
17929
|
+
},
|
|
17930
|
+
"default": "false",
|
|
17931
|
+
"description": "Pins the fire to the bottom of the nearest positioned ancestor instead of\nthe viewport.",
|
|
17932
|
+
"attribute": "contained",
|
|
17933
|
+
"reflects": true
|
|
17934
|
+
},
|
|
17935
|
+
{
|
|
17936
|
+
"kind": "field",
|
|
17937
|
+
"name": "_cols",
|
|
17938
|
+
"type": {
|
|
17939
|
+
"text": "number"
|
|
17940
|
+
},
|
|
17941
|
+
"privacy": "private",
|
|
17942
|
+
"default": "0"
|
|
17943
|
+
},
|
|
17944
|
+
{
|
|
17945
|
+
"kind": "field",
|
|
17946
|
+
"name": "_rows",
|
|
17947
|
+
"type": {
|
|
17948
|
+
"text": "number"
|
|
17949
|
+
},
|
|
17950
|
+
"privacy": "private",
|
|
17951
|
+
"default": "0"
|
|
17952
|
+
},
|
|
17953
|
+
{
|
|
17954
|
+
"kind": "field",
|
|
17955
|
+
"name": "_heat",
|
|
17956
|
+
"privacy": "private",
|
|
17957
|
+
"default": "new Float32Array(0)"
|
|
17958
|
+
},
|
|
17959
|
+
{
|
|
17960
|
+
"kind": "field",
|
|
17961
|
+
"name": "_cooling",
|
|
17962
|
+
"type": {
|
|
17963
|
+
"text": "Float32Array"
|
|
17964
|
+
},
|
|
17965
|
+
"privacy": "private",
|
|
17966
|
+
"default": "new Float32Array(0)"
|
|
17967
|
+
},
|
|
17968
|
+
{
|
|
17969
|
+
"kind": "field",
|
|
17970
|
+
"name": "_time",
|
|
17971
|
+
"type": {
|
|
17972
|
+
"text": "number"
|
|
17973
|
+
},
|
|
17974
|
+
"privacy": "private",
|
|
17975
|
+
"default": "0"
|
|
17976
|
+
},
|
|
17977
|
+
{
|
|
17978
|
+
"kind": "field",
|
|
17979
|
+
"name": "_image",
|
|
17980
|
+
"type": {
|
|
17981
|
+
"text": "ImageData | undefined"
|
|
17982
|
+
},
|
|
17983
|
+
"privacy": "private"
|
|
17984
|
+
},
|
|
17985
|
+
{
|
|
17986
|
+
"kind": "field",
|
|
17987
|
+
"name": "_frame",
|
|
17988
|
+
"type": {
|
|
17989
|
+
"text": "number | undefined"
|
|
17990
|
+
},
|
|
17991
|
+
"privacy": "private"
|
|
17992
|
+
},
|
|
17993
|
+
{
|
|
17994
|
+
"kind": "field",
|
|
17995
|
+
"name": "_lastStep",
|
|
17996
|
+
"type": {
|
|
17997
|
+
"text": "number"
|
|
17998
|
+
},
|
|
17999
|
+
"privacy": "private",
|
|
18000
|
+
"default": "0"
|
|
18001
|
+
},
|
|
18002
|
+
{
|
|
18003
|
+
"kind": "field",
|
|
18004
|
+
"name": "_resizeObserver",
|
|
18005
|
+
"type": {
|
|
18006
|
+
"text": "ResizeObserver | undefined"
|
|
18007
|
+
},
|
|
18008
|
+
"privacy": "private"
|
|
18009
|
+
},
|
|
18010
|
+
{
|
|
18011
|
+
"kind": "field",
|
|
18012
|
+
"name": "_motionQuery",
|
|
18013
|
+
"type": {
|
|
18014
|
+
"text": "MediaQueryList | undefined"
|
|
18015
|
+
},
|
|
18016
|
+
"privacy": "private"
|
|
18017
|
+
},
|
|
18018
|
+
{
|
|
18019
|
+
"kind": "field",
|
|
18020
|
+
"name": "_canvas",
|
|
18021
|
+
"type": {
|
|
18022
|
+
"text": "HTMLCanvasElement | null"
|
|
18023
|
+
},
|
|
18024
|
+
"privacy": "private",
|
|
18025
|
+
"readonly": true
|
|
18026
|
+
},
|
|
18027
|
+
{
|
|
18028
|
+
"kind": "field",
|
|
18029
|
+
"name": "_cellSize",
|
|
18030
|
+
"type": {
|
|
18031
|
+
"text": "number"
|
|
18032
|
+
},
|
|
18033
|
+
"privacy": "private",
|
|
18034
|
+
"readonly": true
|
|
18035
|
+
},
|
|
18036
|
+
{
|
|
18037
|
+
"kind": "field",
|
|
18038
|
+
"name": "_sourceHeat",
|
|
18039
|
+
"type": {
|
|
18040
|
+
"text": "number"
|
|
18041
|
+
},
|
|
18042
|
+
"privacy": "private",
|
|
18043
|
+
"readonly": true
|
|
18044
|
+
},
|
|
18045
|
+
{
|
|
18046
|
+
"kind": "field",
|
|
18047
|
+
"name": "_resize",
|
|
18048
|
+
"privacy": "private",
|
|
18049
|
+
"readonly": true,
|
|
18050
|
+
"description": "Rebuilds the fire grid to cover the host's current box, then restarts it."
|
|
18051
|
+
},
|
|
18052
|
+
{
|
|
18053
|
+
"kind": "field",
|
|
18054
|
+
"name": "_restart",
|
|
18055
|
+
"privacy": "private",
|
|
18056
|
+
"readonly": true,
|
|
18057
|
+
"description": "Animates the fire, or draws one settled frame under reduced motion."
|
|
18058
|
+
},
|
|
18059
|
+
{
|
|
18060
|
+
"kind": "method",
|
|
18061
|
+
"name": "_stop",
|
|
18062
|
+
"privacy": "private",
|
|
18063
|
+
"return": {
|
|
18064
|
+
"type": {
|
|
18065
|
+
"text": "void"
|
|
18066
|
+
}
|
|
18067
|
+
}
|
|
18068
|
+
},
|
|
18069
|
+
{
|
|
18070
|
+
"kind": "field",
|
|
18071
|
+
"name": "_tick",
|
|
18072
|
+
"privacy": "private",
|
|
18073
|
+
"readonly": true
|
|
18074
|
+
},
|
|
18075
|
+
{
|
|
18076
|
+
"kind": "method",
|
|
18077
|
+
"name": "_step",
|
|
18078
|
+
"privacy": "private",
|
|
18079
|
+
"return": {
|
|
18080
|
+
"type": {
|
|
18081
|
+
"text": ""
|
|
18082
|
+
}
|
|
18083
|
+
},
|
|
18084
|
+
"description": "Advances the fire one step: the bottom row is fed with heat and every cell\nrises one row, drifting sideways and cooling at random."
|
|
18085
|
+
},
|
|
18086
|
+
{
|
|
18087
|
+
"kind": "method",
|
|
18088
|
+
"name": "_draw",
|
|
18089
|
+
"privacy": "private",
|
|
18090
|
+
"return": {
|
|
18091
|
+
"type": {
|
|
18092
|
+
"text": "void"
|
|
18093
|
+
}
|
|
18094
|
+
},
|
|
18095
|
+
"description": "Paints the heat grid to the canvas through the palette."
|
|
18096
|
+
}
|
|
18097
|
+
],
|
|
18098
|
+
"attributes": [
|
|
18099
|
+
{
|
|
18100
|
+
"name": "pixel-size",
|
|
18101
|
+
"type": {
|
|
18102
|
+
"text": "number"
|
|
18103
|
+
},
|
|
18104
|
+
"default": "4",
|
|
18105
|
+
"description": "Size of one fire pixel in CSS pixels; larger values look chunkier.",
|
|
18106
|
+
"fieldName": "pixelSize"
|
|
18107
|
+
},
|
|
18108
|
+
{
|
|
18109
|
+
"name": "intensity",
|
|
18110
|
+
"type": {
|
|
18111
|
+
"text": "number"
|
|
18112
|
+
},
|
|
18113
|
+
"default": "1",
|
|
18114
|
+
"description": "Heat of the fire's source, from `0` to `1`. Lowering it shortens the\nflames; `0` lets the fire burn out.",
|
|
18115
|
+
"fieldName": "intensity"
|
|
18116
|
+
},
|
|
18117
|
+
{
|
|
18118
|
+
"name": "contained",
|
|
18119
|
+
"type": {
|
|
18120
|
+
"text": "boolean"
|
|
18121
|
+
},
|
|
18122
|
+
"default": "false",
|
|
18123
|
+
"description": "Pins the fire to the bottom of the nearest positioned ancestor instead of\nthe viewport.",
|
|
18124
|
+
"fieldName": "contained"
|
|
18125
|
+
}
|
|
18126
|
+
],
|
|
18127
|
+
"superclass": {
|
|
18128
|
+
"name": "LitElement",
|
|
18129
|
+
"package": "lit"
|
|
18130
|
+
},
|
|
18131
|
+
"tagName": "pixel-fire",
|
|
18132
|
+
"customElement": true
|
|
18133
|
+
}
|
|
18134
|
+
],
|
|
18135
|
+
"exports": [
|
|
18136
|
+
{
|
|
18137
|
+
"kind": "js",
|
|
18138
|
+
"name": "PixelFire",
|
|
18139
|
+
"declaration": {
|
|
18140
|
+
"name": "PixelFire",
|
|
18141
|
+
"module": "src/pixel-fire.ts"
|
|
18142
|
+
}
|
|
18143
|
+
},
|
|
18144
|
+
{
|
|
18145
|
+
"kind": "custom-element-definition",
|
|
18146
|
+
"name": "pixel-fire",
|
|
18147
|
+
"declaration": {
|
|
18148
|
+
"name": "PixelFire",
|
|
18149
|
+
"module": "src/pixel-fire.ts"
|
|
18150
|
+
}
|
|
18151
|
+
}
|
|
18152
|
+
]
|
|
18153
|
+
},
|
|
17868
18154
|
{
|
|
17869
18155
|
"kind": "javascript-module",
|
|
17870
18156
|
"path": "src/popover-panel.ts",
|
|
@@ -30,7 +30,10 @@ export interface AutocompleteOption {
|
|
|
30
30
|
*
|
|
31
31
|
* Each option may also carry a pre-rendered `icon` (shown before the value)
|
|
32
32
|
* and a `description` (a smaller, muted line under the value); options
|
|
33
|
-
* without them render as a plain value.
|
|
33
|
+
* without them render as a plain value. The selected option's icon also
|
|
34
|
+
* shows inside the field until the text is edited. Picking an option sets
|
|
35
|
+
* `selectedKey`; set `selectedKey` and `value` together to show a selection
|
|
36
|
+
* made elsewhere.
|
|
34
37
|
*
|
|
35
38
|
* Set `clearable` to show an in-field clear action whenever a value is
|
|
36
39
|
* present.
|
|
@@ -67,13 +70,15 @@ export declare class AutocompleteInput extends LitElement {
|
|
|
67
70
|
* this takes priority over the API mode.
|
|
68
71
|
*/
|
|
69
72
|
options: AutocompleteOption[] | null;
|
|
73
|
+
/** Key of the selected option: set by picking one, or by the caller together with `value`. */
|
|
74
|
+
selectedKey: string | null;
|
|
70
75
|
private _suggestions;
|
|
71
76
|
private _open;
|
|
72
77
|
private _activeIndex;
|
|
73
78
|
private _formDisabled;
|
|
74
79
|
private _formFieldConfig;
|
|
75
80
|
private _input?;
|
|
76
|
-
/**
|
|
81
|
+
/** Selected option (picked, or matching `selectedKey`), or null once the input diverges from it. */
|
|
77
82
|
get selectedOption(): AutocompleteOption | null;
|
|
78
83
|
/**
|
|
79
84
|
* Applies or clears label configuration supplied by a wrapping `form-field`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete-input.d.ts","sourceRoot":"","sources":["../src/autocomplete-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAI/F,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAKvC,iFAAiF;AACjF,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,8HAA8H;IAC9H,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,wGAAwG;IACxG,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED
|
|
1
|
+
{"version":3,"file":"autocomplete-input.d.ts","sourceRoot":"","sources":["../src/autocomplete-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAI/F,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAKvC,iFAAiF;AACjF,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,8HAA8H;IAC9H,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,wGAAwG;IACxG,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBACa,iBAAkB,SAAQ,UAAU;;IAC/C,MAAM,CAAC,cAAc,UAAQ;IAE7B,OAAgB,MAAM,4BA4PpB;IAEF,mFAAmF;IACvE,KAAK,SAAM;IACvB,sDAAsD;IAC1C,WAAW,SAAM;IAC7B,8DAA8D;IACjC,QAAQ,UAAS;IAC9C,0DAA0D;IACd,QAAQ,UAAS;IAC7D,oEAAoE;IACxB,SAAS,UAAS;IAC9D,uEAAuE;IAC3D,QAAQ,SAAM;IAC1B,wEAAwE;IAChC,UAAU,SAAO;IACzD,uEAAuE;IAC3C,QAAQ,SAAO;IAC3C,yDAAyD;IACJ,SAAS,SAAK;IACnE;;;;OAIG;IAC6B,OAAO,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAQ;IAC5E,8FAA8F;IACrD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAElE,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAAuC;IAExD,OAAO,CAAC,MAAM,CAAC,CAAmB;IAiBlD,oGAAoG;IACpG,IAAI,cAAc,IAAI,kBAAkB,GAAG,IAAI,CAG9C;IAED;;;OAGG;IACH,CAAC,gBAAgB,CAAC,CAAC,MAAM,EAAE,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAE9D;IAED,UAAmB,UAAU,CAAC,OAAO,EAAE,cAAc,QAQpD;IAED,UAAmB,OAAO,CAAC,OAAO,EAAE,cAAc,QAEjD;IAEQ,oBAAoB,SAK5B;IAED,0FAA0F;IAC1F,iBAAiB,SAKhB;IAED,sEAAsE;IACtE,oBAAoB,CAAC,QAAQ,EAAE,OAAO,QAQrC;IAED,OAAO,CAAC,OAAO;IA8Df,OAAO,CAAC,SAAS;IAuCjB,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,gBAAgB;IAyDxB,OAAO,CAAC,iBAAiB;IA8BhB,MAAM,sBAoEd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,iBAAiB,CAAC;KACzC;CACF"}
|
|
@@ -32,7 +32,10 @@ let instanceCount = 0;
|
|
|
32
32
|
*
|
|
33
33
|
* Each option may also carry a pre-rendered `icon` (shown before the value)
|
|
34
34
|
* and a `description` (a smaller, muted line under the value); options
|
|
35
|
-
* without them render as a plain value.
|
|
35
|
+
* without them render as a plain value. The selected option's icon also
|
|
36
|
+
* shows inside the field until the text is edited. Picking an option sets
|
|
37
|
+
* `selectedKey`; set `selectedKey` and `value` together to show a selection
|
|
38
|
+
* made elsewhere.
|
|
36
39
|
*
|
|
37
40
|
* Set `clearable` to show an in-field clear action whenever a value is
|
|
38
41
|
* present.
|
|
@@ -68,6 +71,8 @@ let AutocompleteInput = class AutocompleteInput extends LitElement {
|
|
|
68
71
|
* this takes priority over the API mode.
|
|
69
72
|
*/
|
|
70
73
|
this.options = null;
|
|
74
|
+
/** Key of the selected option: set by picking one, or by the caller together with `value`. */
|
|
75
|
+
this.selectedKey = null;
|
|
71
76
|
this._suggestions = [];
|
|
72
77
|
this._open = false;
|
|
73
78
|
this._activeIndex = -1;
|
|
@@ -119,6 +124,19 @@ let AutocompleteInput = class AutocompleteInput extends LitElement {
|
|
|
119
124
|
.field-shell.clearable input {
|
|
120
125
|
padding-right: 2rem;
|
|
121
126
|
}
|
|
127
|
+
.field-shell.has-icon input {
|
|
128
|
+
padding-left: 2rem;
|
|
129
|
+
}
|
|
130
|
+
.field-icon {
|
|
131
|
+
position: absolute;
|
|
132
|
+
top: 50%;
|
|
133
|
+
left: 0.75rem;
|
|
134
|
+
display: inline-flex;
|
|
135
|
+
line-height: 0;
|
|
136
|
+
transform: translateY(-50%);
|
|
137
|
+
color: var(--ui-text-muted, #64748b);
|
|
138
|
+
pointer-events: none;
|
|
139
|
+
}
|
|
122
140
|
.clear-button {
|
|
123
141
|
position: absolute;
|
|
124
142
|
top: 0;
|
|
@@ -192,6 +210,12 @@ let AutocompleteInput = class AutocompleteInput extends LitElement {
|
|
|
192
210
|
.field-shell.floating .clear-button {
|
|
193
211
|
top: 0.5rem;
|
|
194
212
|
}
|
|
213
|
+
.field-shell.floating .field-icon {
|
|
214
|
+
top: 2rem;
|
|
215
|
+
}
|
|
216
|
+
.field-shell.has-icon .floating-label {
|
|
217
|
+
left: 2rem;
|
|
218
|
+
}
|
|
195
219
|
.field-shell.floating.has-value .floating-label,
|
|
196
220
|
.field-shell.floating:focus-within .floating-label {
|
|
197
221
|
top: 0.25rem;
|
|
@@ -331,11 +355,11 @@ let AutocompleteInput = class AutocompleteInput extends LitElement {
|
|
|
331
355
|
get #isDisabled() {
|
|
332
356
|
return this.disabled || this._formDisabled;
|
|
333
357
|
}
|
|
334
|
-
/**
|
|
358
|
+
/** Selected option (picked, or matching `selectedKey`), or null once the input diverges from it. */
|
|
335
359
|
get selectedOption() {
|
|
336
360
|
if (this.#lastPicked && this.#lastPicked.value === this.value)
|
|
337
361
|
return this.#lastPicked;
|
|
338
|
-
return null;
|
|
362
|
+
return this.options?.find((o) => o.key === this.selectedKey && o.value === this.value) ?? null;
|
|
339
363
|
}
|
|
340
364
|
/**
|
|
341
365
|
* Applies or clears label configuration supplied by a wrapping `form-field`.
|
|
@@ -520,6 +544,7 @@ let AutocompleteInput = class AutocompleteInput extends LitElement {
|
|
|
520
544
|
}
|
|
521
545
|
#selectOption(o) {
|
|
522
546
|
this.value = o.value;
|
|
547
|
+
this.selectedKey = o.key;
|
|
523
548
|
this.#lastPicked = o;
|
|
524
549
|
this._open = false;
|
|
525
550
|
this._suggestions = [];
|
|
@@ -588,12 +613,16 @@ let AutocompleteInput = class AutocompleteInput extends LitElement {
|
|
|
588
613
|
const expanded = this._open && !this.#isDisabled;
|
|
589
614
|
const floating = Boolean(this._formFieldConfig?.floating) && Boolean(this._formFieldConfig?.label);
|
|
590
615
|
const showClear = this.clearable && Boolean(this.value) && !this.#isDisabled;
|
|
616
|
+
const icon = this.selectedOption?.icon;
|
|
591
617
|
return html `
|
|
592
618
|
<div
|
|
593
619
|
class="field-shell ${this.clearable ? "clearable" : ""} ${floating
|
|
594
620
|
? "floating"
|
|
595
|
-
: ""} ${this.value ? "has-value" : ""} ${this.#isDisabled ? "disabled" : ""}
|
|
621
|
+
: ""} ${this.value ? "has-value" : ""} ${this.#isDisabled ? "disabled" : ""} ${icon
|
|
622
|
+
? "has-icon"
|
|
623
|
+
: ""}"
|
|
596
624
|
>
|
|
625
|
+
${icon ? html `<span class="field-icon" aria-hidden="true">${icon}</span>` : nothing}
|
|
597
626
|
${floating
|
|
598
627
|
? html `
|
|
599
628
|
<label class="floating-label" for=${this.#inputId}>
|
|
@@ -675,6 +704,9 @@ __decorate([
|
|
|
675
704
|
__decorate([
|
|
676
705
|
property({ attribute: false })
|
|
677
706
|
], AutocompleteInput.prototype, "options", void 0);
|
|
707
|
+
__decorate([
|
|
708
|
+
property({ attribute: "selected-key" })
|
|
709
|
+
], AutocompleteInput.prototype, "selectedKey", void 0);
|
|
678
710
|
__decorate([
|
|
679
711
|
state()
|
|
680
712
|
], AutocompleteInput.prototype, "_suggestions", void 0);
|