@fluid-topics/ft-filter 0.3.40 → 0.3.45

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.
@@ -13,114 +13,119 @@ export const FtFilterCssVariables = {
13
13
  };
14
14
  export const styles = [
15
15
  FtTypographyCaption,
16
+ //language=css
16
17
  css `
17
- :host {
18
- display: flex;
19
- max-height: 100%;
20
- max-width: 100%;
21
- }
22
-
23
- .ft-filter--container {
24
- flex-grow: 1;
25
- display: flex;
26
- flex-direction: column;
27
- max-height: 100%;
28
- max-width: 100%;
29
- color: ${FtFilterCssVariables.colorOnSurface};
30
- }
31
-
32
- .ft-filter--header {
33
- display: flex;
34
- flex-wrap: wrap;
35
- gap: 4px;
36
- flex-shrink: 0;
37
- padding: 0 10px;
38
- margin-bottom: 8px;
39
- ${setVariable(FtTypographyCssVariables.fontSize, "14px")};
40
- }
41
-
42
- .ft-filter--header ft-button {
43
- flex-shrink: 0;
44
- margin-left: auto;
45
- ${setVariable(FtButtonCssVariables.iconSize, "18px")};
46
- }
47
-
48
- .ft-filter--label {
49
- display: block;
50
- flex-shrink: 1;
51
- flex-grow: 1;
52
- word-break: break-word;
53
- ${setVariable(FtTypographyCssVariables.lineHeight, "22px")};
54
- ${setVariable(FtTypographyCssVariables.fontWeight, "bold")};
55
- }
56
-
57
- .ft-filter--filter {
58
- flex-shrink: 0;
59
- display: flex;
60
- margin: 0;
61
- margin-bottom: 8px;
62
- padding: 0 10px;
63
- overflow: hidden;
64
- height: 32px;
65
- transition: height ${FtFilterCssVariables.transitionDuration} ${FtFilterCssVariables.transitionTimingFunction},
66
- margin ${FtFilterCssVariables.transitionDuration} ${FtFilterCssVariables.transitionTimingFunction};
67
- transition-delay: 500ms;
68
- }
69
-
70
- .ft-filter--filter[hidden] {
71
- height: 0;
72
- margin-bottom: 0;
73
- }
74
-
75
- input {
76
- display: block;
77
- width: 100%;
78
- border-radius: 4px;
79
- border: 1px solid ${FtFilterCssVariables.colorOutline};
80
- padding: 4px;
81
- background-color: ${FtFilterCssVariables.colorSurface};
82
- color: ${FtFilterCssVariables.colorOnSurface};
83
- outline-color: ${FtFilterCssVariables.colorPrimary};
84
- }
85
-
86
- input::placeholder {
87
- color: ${FtFilterCssVariables.colorOnSurfaceMedium};
88
- }
89
-
90
- .ft-filter--values {
91
- flex-grow: 1;
92
- flex-shrink: 1;
93
- max-width: 100%;
94
- overflow-x: hidden;
95
- overflow-y: auto;
96
- }
97
-
98
- .ft-filter--separator {
99
- border-top: 1px solid ${FtFilterCssVariables.colorOutline};
100
- margin: 4px 10px;
101
- }
102
-
103
- .ft-filter--levels-container {
104
- position: relative;
105
- overflow: hidden;
106
- }
107
-
108
- .ft-filter--levels {
109
- position: relative;
110
- overflow: hidden;
111
- }
112
-
113
- ft-filter-level {
114
- width: 100%;
115
- }
116
-
117
- .ft-filter--level-left {
118
- height: 0;
119
- }
120
-
121
- slot {
122
- display: none;
123
- }
124
- `
18
+ :host {
19
+ display: flex;
20
+ max-height: 100%;
21
+ max-width: 100%;
22
+ }
23
+
24
+ .ft-filter--container {
25
+ flex-grow: 1;
26
+ display: flex;
27
+ flex-direction: column;
28
+ max-height: 100%;
29
+ max-width: 100%;
30
+ color: ${FtFilterCssVariables.colorOnSurface};
31
+ }
32
+
33
+ .ft-filter--header {
34
+ display: flex;
35
+ flex-wrap: wrap;
36
+ gap: 4px;
37
+ flex-shrink: 0;
38
+ padding: 0 10px;
39
+ margin-bottom: 8px;
40
+ ${setVariable(FtTypographyCssVariables.fontSize, "14px")};
41
+ }
42
+
43
+ .ft-filter--header ft-button {
44
+ flex-shrink: 0;
45
+ margin-left: auto;
46
+ ${setVariable(FtButtonCssVariables.iconSize, "18px")};
47
+ }
48
+
49
+ .ft-filter--label {
50
+ display: block;
51
+ flex-shrink: 1;
52
+ flex-grow: 1;
53
+ word-break: break-word;
54
+ ${setVariable(FtTypographyCssVariables.lineHeight, "22px")};
55
+ ${setVariable(FtTypographyCssVariables.fontWeight, "bold")};
56
+ }
57
+
58
+ .ft-filter--filter {
59
+ flex-shrink: 0;
60
+ display: flex;
61
+ margin: 0;
62
+ margin-bottom: 8px;
63
+ padding: 0 10px;
64
+ overflow: hidden;
65
+ height: 32px;
66
+ transition: height ${FtFilterCssVariables.transitionDuration} ${FtFilterCssVariables.transitionTimingFunction},
67
+ margin ${FtFilterCssVariables.transitionDuration} ${FtFilterCssVariables.transitionTimingFunction};
68
+ transition-delay: 500ms;
69
+ }
70
+
71
+ .ft-filter--filter[hidden] {
72
+ height: 0;
73
+ margin-bottom: 0;
74
+ }
75
+
76
+ input {
77
+ display: block;
78
+ width: 100%;
79
+ border-radius: 4px;
80
+ border: 1px solid ${FtFilterCssVariables.colorOutline};
81
+ padding: 4px;
82
+ background-color: ${FtFilterCssVariables.colorSurface};
83
+ color: ${FtFilterCssVariables.colorOnSurface};
84
+ outline-color: ${FtFilterCssVariables.colorPrimary};
85
+ }
86
+
87
+ input::placeholder {
88
+ color: ${FtFilterCssVariables.colorOnSurfaceMedium};
89
+ }
90
+
91
+ input:placeholder-shown {
92
+ text-overflow: ellipsis;
93
+ }
94
+
95
+ .ft-filter--values {
96
+ flex-grow: 1;
97
+ flex-shrink: 1;
98
+ max-width: 100%;
99
+ overflow-x: hidden;
100
+ overflow-y: auto;
101
+ }
102
+
103
+ .ft-filter--separator {
104
+ border-top: 1px solid ${FtFilterCssVariables.colorOutline};
105
+ margin: 4px 10px;
106
+ }
107
+
108
+ .ft-filter--levels-container {
109
+ position: relative;
110
+ overflow: hidden;
111
+ }
112
+
113
+ .ft-filter--levels {
114
+ position: relative;
115
+ overflow: hidden;
116
+ }
117
+
118
+ ft-filter-level {
119
+ width: 100%;
120
+ }
121
+
122
+ .ft-filter--level-left {
123
+ height: 0;
124
+ }
125
+
126
+ slot {
127
+ display: none;
128
+ }
129
+ `
125
130
  ];
126
131
  //# sourceMappingURL=ft-filter.css.js.map
@@ -46,7 +46,8 @@ export class FtFilter extends FtLitElement {
46
46
  render() {
47
47
  var _a, _b;
48
48
  const valuesSelected = this.flatOptions.some(o => o.selected);
49
- let showFilter = this.withScroll || this.filter || ((_b = (_a = this.lastLevel) === null || _a === void 0 ? void 0 : _a.hasHiddenValues) !== null && _b !== void 0 ? _b : false);
49
+ const showFilter = this.withScroll || this.filter || ((_b = (_a = this.lastLevel) === null || _a === void 0 ? void 0 : _a.hasHiddenValues) !== null && _b !== void 0 ? _b : false);
50
+ const placeholder = this.filterPlaceHolder.replace("{0}", this.label);
50
51
  return html `
51
52
  <div class="ft-filter--container ${this.disabled ? "ft-filter--disabled" : ""}"
52
53
  part="container">
@@ -66,7 +67,8 @@ export class FtFilter extends FtLitElement {
66
67
  part="input"
67
68
  class="ft-typography--caption"
68
69
  ?disabled=${!showFilter}
69
- placeholder="${this.filterPlaceHolder.replace("{0}", this.label)}"
70
+ placeholder="${placeholder}"
71
+ size="${showFilter ? placeholder.length : 0}"
70
72
  @search=${this.onFilterChange}
71
73
  @keyup=${this.onFilterChange}>
72
74
  </div>
@@ -1038,114 +1038,118 @@ const V=Symbol.for(""),H=t=>{if((null==t?void 0:t.r)===V)return null==t?void 0:t
1038
1038
  ></ft-button>
1039
1039
  </div>
1040
1040
  `}updated(t){var i;super.updated(t),this.contentSlot&&(this.resizeObserver.observe(this.contentSlot),this.listenedContainer!==this.contentSlot&&(this.listenedContainer&&this.listenedContainer.removeEventListener("scroll",this.updateScrollCallback),this.listenedContainer=this.contentSlot,null===(i=this.listenedContainer)||void 0===i||i.addEventListener("scroll",this.updateScrollCallback))),t.has("horizontal")&&(this.horizontal?(this.offsetAttribute="offsetLeft",this.scrollAttribute="scrollLeft",this.sizeAttribute="clientWidth",this.scrollSizeAttribute="scrollWidth"):(this.offsetAttribute="offsetTop",this.scrollAttribute="scrollTop",this.sizeAttribute="clientHeight",this.scrollSizeAttribute="scrollHeight")),t.has("currentElement")&&this.dispatchEvent(new xe(this.currentElement,this.elements[this.currentElement]))}onScroll(){this.scrollDebouncer.run((()=>this.snap())),this.scheduleUpdateScroll()}snap(){let t=this.closestElementFromStart();if(null!=t){const i=this.getDistanceFromStart(t);Math.abs(this.contentSlot[this.scrollAttribute]+this.contentSlot[this.sizeAttribute]-this.contentSlot[this.scrollSizeAttribute])<i&&(t=this.lastElement),this.scrollToElement(t)}}scrollToElement(t){var i,e;t&&(this.horizontal?null===(i=this.contentSlot)||void 0===i||i.scrollTo({left:this.getOffset(t)-this.controlsSize,behavior:"smooth"}):null===(e=this.contentSlot)||void 0===e||e.scrollTo({top:this.getOffset(t)-this.controlsSize,behavior:"smooth"}),this.currentElement=this.elements.indexOf(t))}onSlotChange(){var t,i;this.elements=null!==(i=null===(t=this.contentSlot)||void 0===t?void 0:t.assignedElements().map((t=>t)))&&void 0!==i?i:[],this.scheduleUpdateScroll()}closestElementFromStart(){return this.elements[this.closestIndexFromStart()]}closestIndexFromStart(){let t=-1;for(let i=0;i<this.elements.length;i++)(t<0||this.getDistanceFromStart(this.elements[i])<this.getDistanceFromStart(this.elements[t]))&&(t=i);return t}scheduleUpdateScroll(){this.updateScrollDebouncer.run((()=>this.updateScroll()))}updateScroll(){null!=this.contentSlot?(this.withScroll=this.contentSlot[this.scrollSizeAttribute]>this.contentSlot[this.sizeAttribute],this.startReached=0===this.contentSlot[this.scrollAttribute],this.endReached=this.contentSlot[this.scrollAttribute]+this.contentSlot[this.sizeAttribute]+1>=this.contentSlot[this.scrollSizeAttribute]):(this.withScroll=!1,this.startReached=!0,this.endReached=!0)}get lastElement(){return this.elements[this.elements.length-1]}get firstElementOffset(){let t=this.elements[0];return t?t[this.offsetAttribute]:0}get controlsSize(){return this.controls?36:0}get nextSize(){return this.endReached?0:this.controlsSize}get prevSize(){return this.startReached?0:this.controlsSize}getOffset(t){return t[this.offsetAttribute]-this.firstElementOffset}getDistanceFromStart(t){const i=t===this.elements[0]?0:this.controlsSize;return Math.abs(this.getOffset(t)-this.contentSlot[this.scrollAttribute]-i)}}ge.elementDefinitions={"ft-button":Wi},ge.styles=ve,be([o.property({type:Boolean})],ge.prototype,"horizontal",void 0),be([o.property({type:Boolean})],ge.prototype,"hideScrollbar",void 0),be([o.property({type:Boolean})],ge.prototype,"controls",void 0),be([o.property({type:Boolean})],ge.prototype,"limitSize",void 0),be([o.state()],ge.prototype,"elements",void 0),be([o.state()],ge.prototype,"currentElement",void 0),be([o.state()],ge.prototype,"withScroll",void 0),be([o.state()],ge.prototype,"startReached",void 0),be([o.state()],ge.prototype,"endReached",void 0),be([o.query(".ft-snap-scroll--content")],ge.prototype,"contentSlot",void 0),i.customElement("ft-snap-scroll")(ge);const ye={colorOutline:i.FtCssVariableFactory.external(i.designSystemVariables.colorOutline,"Design system"),colorOnSurface:i.FtCssVariableFactory.external(i.designSystemVariables.colorOnSurface,"Design system"),colorOnSurfaceMedium:i.FtCssVariableFactory.external(i.designSystemVariables.colorOnSurfaceMedium,"Design system"),colorPrimary:i.FtCssVariableFactory.external(i.designSystemVariables.colorPrimary,"Design system"),colorSurface:i.FtCssVariableFactory.external(i.designSystemVariables.colorSurface,"Design system"),transitionDuration:i.FtCssVariableFactory.external(i.designSystemVariables.transitionDuration,"Design system"),transitionTimingFunction:i.FtCssVariableFactory.external(i.designSystemVariables.transitionTimingFunction,"Design system")},me=[Qt,e.css`
1041
- :host {
1042
- display: flex;
1043
- max-height: 100%;
1044
- max-width: 100%;
1045
- }
1046
-
1047
- .ft-filter--container {
1048
- flex-grow: 1;
1049
- display: flex;
1050
- flex-direction: column;
1051
- max-height: 100%;
1052
- max-width: 100%;
1053
- color: ${ye.colorOnSurface};
1054
- }
1055
-
1056
- .ft-filter--header {
1057
- display: flex;
1058
- flex-wrap: wrap;
1059
- gap: 4px;
1060
- flex-shrink: 0;
1061
- padding: 0 10px;
1062
- margin-bottom: 8px;
1063
- ${i.setVariable(X.fontSize,"14px")};
1064
- }
1065
-
1066
- .ft-filter--header ft-button {
1067
- flex-shrink: 0;
1068
- margin-left: auto;
1069
- ${i.setVariable(_i.iconSize,"18px")};
1070
- }
1071
-
1072
- .ft-filter--label {
1073
- display: block;
1074
- flex-shrink: 1;
1075
- flex-grow: 1;
1076
- word-break: break-word;
1077
- ${i.setVariable(X.lineHeight,"22px")};
1078
- ${i.setVariable(X.fontWeight,"bold")};
1079
- }
1080
-
1081
- .ft-filter--filter {
1082
- flex-shrink: 0;
1083
- display: flex;
1084
- margin: 0;
1085
- margin-bottom: 8px;
1086
- padding: 0 10px;
1087
- overflow: hidden;
1088
- height: 32px;
1089
- transition: height ${ye.transitionDuration} ${ye.transitionTimingFunction},
1090
- margin ${ye.transitionDuration} ${ye.transitionTimingFunction};
1091
- transition-delay: 500ms;
1092
- }
1093
-
1094
- .ft-filter--filter[hidden] {
1095
- height: 0;
1096
- margin-bottom: 0;
1097
- }
1098
-
1099
- input {
1100
- display: block;
1101
- width: 100%;
1102
- border-radius: 4px;
1103
- border: 1px solid ${ye.colorOutline};
1104
- padding: 4px;
1105
- background-color: ${ye.colorSurface};
1106
- color: ${ye.colorOnSurface};
1107
- outline-color: ${ye.colorPrimary};
1108
- }
1109
-
1110
- input::placeholder {
1111
- color: ${ye.colorOnSurfaceMedium};
1112
- }
1113
-
1114
- .ft-filter--values {
1115
- flex-grow: 1;
1116
- flex-shrink: 1;
1117
- max-width: 100%;
1118
- overflow-x: hidden;
1119
- overflow-y: auto;
1120
- }
1121
-
1122
- .ft-filter--separator {
1123
- border-top: 1px solid ${ye.colorOutline};
1124
- margin: 4px 10px;
1125
- }
1126
-
1127
- .ft-filter--levels-container {
1128
- position: relative;
1129
- overflow: hidden;
1130
- }
1131
-
1132
- .ft-filter--levels {
1133
- position: relative;
1134
- overflow: hidden;
1135
- }
1136
-
1137
- ft-filter-level {
1138
- width: 100%;
1139
- }
1140
-
1141
- .ft-filter--level-left {
1142
- height: 0;
1143
- }
1144
-
1145
- slot {
1146
- display: none;
1147
- }
1148
- `];var $e=function(t,i,e,o){for(var s,r=arguments.length,n=r<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,e):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(i,e,n):s(i,e))||n);return r>3&&n&&Object.defineProperty(i,e,n),n};class ke extends CustomEvent{constructor(t){super("change",{detail:t})}}class we extends i.FtLitElement{constructor(){super(...arguments),this.id="",this.label="",this.filterPlaceHolder="Filter {0}",this.clearButtonLabel="Clear",this.moreValuesButtonLabel="More",this.noValuesLabel="No values available",this.options=[],this.multivalued=!1,this.disabled=!1,this.raiseSelectedOptions=!1,this.displayedValuesLimit=0,this.hideClearButton=!1,this.withScroll=!1,this.filter="",this.displayedLevels=[],this.scrollResizeObserver=new ResizeObserver((()=>this.updateScroll())),this.levelsScrollDebouncer=new i.Debouncer(300),this.changeDebouncer=new i.Debouncer(10)}get flatOptions(){return ni(this.options,(t=>{var i;return null!==(i=t.subOptions)&&void 0!==i?i:[]}))}render(){var t,i;const o=this.flatOptions.some((t=>t.selected));let s=this.withScroll||this.filter||null!==(i=null===(t=this.lastLevel)||void 0===t?void 0:t.hasHiddenValues)&&void 0!==i&&i;return e.html`
1041
+ :host {
1042
+ display: flex;
1043
+ max-height: 100%;
1044
+ max-width: 100%;
1045
+ }
1046
+
1047
+ .ft-filter--container {
1048
+ flex-grow: 1;
1049
+ display: flex;
1050
+ flex-direction: column;
1051
+ max-height: 100%;
1052
+ max-width: 100%;
1053
+ color: ${ye.colorOnSurface};
1054
+ }
1055
+
1056
+ .ft-filter--header {
1057
+ display: flex;
1058
+ flex-wrap: wrap;
1059
+ gap: 4px;
1060
+ flex-shrink: 0;
1061
+ padding: 0 10px;
1062
+ margin-bottom: 8px;
1063
+ ${i.setVariable(X.fontSize,"14px")};
1064
+ }
1065
+
1066
+ .ft-filter--header ft-button {
1067
+ flex-shrink: 0;
1068
+ margin-left: auto;
1069
+ ${i.setVariable(_i.iconSize,"18px")};
1070
+ }
1071
+
1072
+ .ft-filter--label {
1073
+ display: block;
1074
+ flex-shrink: 1;
1075
+ flex-grow: 1;
1076
+ word-break: break-word;
1077
+ ${i.setVariable(X.lineHeight,"22px")};
1078
+ ${i.setVariable(X.fontWeight,"bold")};
1079
+ }
1080
+
1081
+ .ft-filter--filter {
1082
+ flex-shrink: 0;
1083
+ display: flex;
1084
+ margin: 0;
1085
+ margin-bottom: 8px;
1086
+ padding: 0 10px;
1087
+ overflow: hidden;
1088
+ height: 32px;
1089
+ transition: height ${ye.transitionDuration} ${ye.transitionTimingFunction},
1090
+ margin ${ye.transitionDuration} ${ye.transitionTimingFunction};
1091
+ transition-delay: 500ms;
1092
+ }
1093
+
1094
+ .ft-filter--filter[hidden] {
1095
+ height: 0;
1096
+ margin-bottom: 0;
1097
+ }
1098
+
1099
+ input {
1100
+ display: block;
1101
+ width: 100%;
1102
+ border-radius: 4px;
1103
+ border: 1px solid ${ye.colorOutline};
1104
+ padding: 4px;
1105
+ background-color: ${ye.colorSurface};
1106
+ color: ${ye.colorOnSurface};
1107
+ outline-color: ${ye.colorPrimary};
1108
+ }
1109
+
1110
+ input::placeholder {
1111
+ color: ${ye.colorOnSurfaceMedium};
1112
+ }
1113
+
1114
+ input:placeholder-shown {
1115
+ text-overflow: ellipsis;
1116
+ }
1117
+
1118
+ .ft-filter--values {
1119
+ flex-grow: 1;
1120
+ flex-shrink: 1;
1121
+ max-width: 100%;
1122
+ overflow-x: hidden;
1123
+ overflow-y: auto;
1124
+ }
1125
+
1126
+ .ft-filter--separator {
1127
+ border-top: 1px solid ${ye.colorOutline};
1128
+ margin: 4px 10px;
1129
+ }
1130
+
1131
+ .ft-filter--levels-container {
1132
+ position: relative;
1133
+ overflow: hidden;
1134
+ }
1135
+
1136
+ .ft-filter--levels {
1137
+ position: relative;
1138
+ overflow: hidden;
1139
+ }
1140
+
1141
+ ft-filter-level {
1142
+ width: 100%;
1143
+ }
1144
+
1145
+ .ft-filter--level-left {
1146
+ height: 0;
1147
+ }
1148
+
1149
+ slot {
1150
+ display: none;
1151
+ }
1152
+ `];var $e=function(t,i,e,o){for(var s,r=arguments.length,n=r<3?i:null===o?o=Object.getOwnPropertyDescriptor(i,e):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(i,e,n):s(i,e))||n);return r>3&&n&&Object.defineProperty(i,e,n),n};class ke extends CustomEvent{constructor(t){super("change",{detail:t})}}class we extends i.FtLitElement{constructor(){super(...arguments),this.id="",this.label="",this.filterPlaceHolder="Filter {0}",this.clearButtonLabel="Clear",this.moreValuesButtonLabel="More",this.noValuesLabel="No values available",this.options=[],this.multivalued=!1,this.disabled=!1,this.raiseSelectedOptions=!1,this.displayedValuesLimit=0,this.hideClearButton=!1,this.withScroll=!1,this.filter="",this.displayedLevels=[],this.scrollResizeObserver=new ResizeObserver((()=>this.updateScroll())),this.levelsScrollDebouncer=new i.Debouncer(300),this.changeDebouncer=new i.Debouncer(10)}get flatOptions(){return ni(this.options,(t=>{var i;return null!==(i=t.subOptions)&&void 0!==i?i:[]}))}render(){var t,i;const o=this.flatOptions.some((t=>t.selected)),s=this.withScroll||this.filter||null!==(i=null===(t=this.lastLevel)||void 0===t?void 0:t.hasHiddenValues)&&void 0!==i&&i,r=this.filterPlaceHolder.replace("{0}",this.label);return e.html`
1149
1153
  <div class="ft-filter--container ${this.disabled?"ft-filter--disabled":""}"
1150
1154
  part="container">
1151
1155
  ${this.label||o?e.html`
@@ -1164,7 +1168,8 @@ const V=Symbol.for(""),H=t=>{if((null==t?void 0:t.r)===V)return null==t?void 0:t
1164
1168
  part="input"
1165
1169
  class="ft-typography--caption"
1166
1170
  ?disabled=${!s}
1167
- placeholder="${this.filterPlaceHolder.replace("{0}",this.label)}"
1171
+ placeholder="${r}"
1172
+ size="${s?r.length:0}"
1168
1173
  @search=${this.onFilterChange}
1169
1174
  @keyup=${this.onFilterChange}>
1170
1175
  </div>
@@ -1157,114 +1157,118 @@ class Ni extends qe{constructor(t){if(super(t),this.it=Y,t.type!==Ze)throw Error
1157
1157
  ></ft-button>
1158
1158
  </div>
1159
1159
  `}updated(t){var e;super.updated(t),this.contentSlot&&(this.resizeObserver.observe(this.contentSlot),this.listenedContainer!==this.contentSlot&&(this.listenedContainer&&this.listenedContainer.removeEventListener("scroll",this.updateScrollCallback),this.listenedContainer=this.contentSlot,null===(e=this.listenedContainer)||void 0===e||e.addEventListener("scroll",this.updateScrollCallback))),t.has("horizontal")&&(this.horizontal?(this.offsetAttribute="offsetLeft",this.scrollAttribute="scrollLeft",this.sizeAttribute="clientWidth",this.scrollSizeAttribute="scrollWidth"):(this.offsetAttribute="offsetTop",this.scrollAttribute="scrollTop",this.sizeAttribute="clientHeight",this.scrollSizeAttribute="scrollHeight")),t.has("currentElement")&&this.dispatchEvent(new yo(this.currentElement,this.elements[this.currentElement]))}onScroll(){this.scrollDebouncer.run((()=>this.snap())),this.scheduleUpdateScroll()}snap(){let t=this.closestElementFromStart();if(null!=t){const e=this.getDistanceFromStart(t);Math.abs(this.contentSlot[this.scrollAttribute]+this.contentSlot[this.sizeAttribute]-this.contentSlot[this.scrollSizeAttribute])<e&&(t=this.lastElement),this.scrollToElement(t)}}scrollToElement(t){var e,i;t&&(this.horizontal?null===(e=this.contentSlot)||void 0===e||e.scrollTo({left:this.getOffset(t)-this.controlsSize,behavior:"smooth"}):null===(i=this.contentSlot)||void 0===i||i.scrollTo({top:this.getOffset(t)-this.controlsSize,behavior:"smooth"}),this.currentElement=this.elements.indexOf(t))}onSlotChange(){var t,e;this.elements=null!==(e=null===(t=this.contentSlot)||void 0===t?void 0:t.assignedElements().map((t=>t)))&&void 0!==e?e:[],this.scheduleUpdateScroll()}closestElementFromStart(){return this.elements[this.closestIndexFromStart()]}closestIndexFromStart(){let t=-1;for(let e=0;e<this.elements.length;e++)(t<0||this.getDistanceFromStart(this.elements[e])<this.getDistanceFromStart(this.elements[t]))&&(t=e);return t}scheduleUpdateScroll(){this.updateScrollDebouncer.run((()=>this.updateScroll()))}updateScroll(){null!=this.contentSlot?(this.withScroll=this.contentSlot[this.scrollSizeAttribute]>this.contentSlot[this.sizeAttribute],this.startReached=0===this.contentSlot[this.scrollAttribute],this.endReached=this.contentSlot[this.scrollAttribute]+this.contentSlot[this.sizeAttribute]+1>=this.contentSlot[this.scrollSizeAttribute]):(this.withScroll=!1,this.startReached=!0,this.endReached=!0)}get lastElement(){return this.elements[this.elements.length-1]}get firstElementOffset(){let t=this.elements[0];return t?t[this.offsetAttribute]:0}get controlsSize(){return this.controls?36:0}get nextSize(){return this.endReached?0:this.controlsSize}get prevSize(){return this.startReached?0:this.controlsSize}getOffset(t){return t[this.offsetAttribute]-this.firstElementOffset}getDistanceFromStart(t){const e=t===this.elements[0]?0:this.controlsSize;return Math.abs(this.getOffset(t)-this.contentSlot[this.scrollAttribute]-e)}}go.elementDefinitions={"ft-button":Hi},go.styles=bo,xo([o({type:Boolean})],go.prototype,"horizontal",void 0),xo([o({type:Boolean})],go.prototype,"hideScrollbar",void 0),xo([o({type:Boolean})],go.prototype,"controls",void 0),xo([o({type:Boolean})],go.prototype,"limitSize",void 0),xo([s()],go.prototype,"elements",void 0),xo([s()],go.prototype,"currentElement",void 0),xo([s()],go.prototype,"withScroll",void 0),xo([s()],go.prototype,"startReached",void 0),xo([s()],go.prototype,"endReached",void 0),xo([n(".ft-snap-scroll--content")],go.prototype,"contentSlot",void 0),c("ft-snap-scroll")(go);const mo={colorOutline:xt.external(gt.colorOutline,"Design system"),colorOnSurface:xt.external(gt.colorOnSurface,"Design system"),colorOnSurfaceMedium:xt.external(gt.colorOnSurfaceMedium,"Design system"),colorPrimary:xt.external(gt.colorPrimary,"Design system"),colorSurface:xt.external(gt.colorSurface,"Design system"),transitionDuration:xt.external(gt.transitionDuration,"Design system"),transitionTimingFunction:xt.external(gt.transitionTimingFunction,"Design system")},$o=[Te,y`
1160
- :host {
1161
- display: flex;
1162
- max-height: 100%;
1163
- max-width: 100%;
1164
- }
1165
-
1166
- .ft-filter--container {
1167
- flex-grow: 1;
1168
- display: flex;
1169
- flex-direction: column;
1170
- max-height: 100%;
1171
- max-width: 100%;
1172
- color: ${mo.colorOnSurface};
1173
- }
1174
-
1175
- .ft-filter--header {
1176
- display: flex;
1177
- flex-wrap: wrap;
1178
- gap: 4px;
1179
- flex-shrink: 0;
1180
- padding: 0 10px;
1181
- margin-bottom: 8px;
1182
- ${yt(Ut.fontSize,"14px")};
1183
- }
1184
-
1185
- .ft-filter--header ft-button {
1186
- flex-shrink: 0;
1187
- margin-left: auto;
1188
- ${yt(Ti.iconSize,"18px")};
1189
- }
1190
-
1191
- .ft-filter--label {
1192
- display: block;
1193
- flex-shrink: 1;
1194
- flex-grow: 1;
1195
- word-break: break-word;
1196
- ${yt(Ut.lineHeight,"22px")};
1197
- ${yt(Ut.fontWeight,"bold")};
1198
- }
1199
-
1200
- .ft-filter--filter {
1201
- flex-shrink: 0;
1202
- display: flex;
1203
- margin: 0;
1204
- margin-bottom: 8px;
1205
- padding: 0 10px;
1206
- overflow: hidden;
1207
- height: 32px;
1208
- transition: height ${mo.transitionDuration} ${mo.transitionTimingFunction},
1209
- margin ${mo.transitionDuration} ${mo.transitionTimingFunction};
1210
- transition-delay: 500ms;
1211
- }
1212
-
1213
- .ft-filter--filter[hidden] {
1214
- height: 0;
1215
- margin-bottom: 0;
1216
- }
1217
-
1218
- input {
1219
- display: block;
1220
- width: 100%;
1221
- border-radius: 4px;
1222
- border: 1px solid ${mo.colorOutline};
1223
- padding: 4px;
1224
- background-color: ${mo.colorSurface};
1225
- color: ${mo.colorOnSurface};
1226
- outline-color: ${mo.colorPrimary};
1227
- }
1228
-
1229
- input::placeholder {
1230
- color: ${mo.colorOnSurfaceMedium};
1231
- }
1232
-
1233
- .ft-filter--values {
1234
- flex-grow: 1;
1235
- flex-shrink: 1;
1236
- max-width: 100%;
1237
- overflow-x: hidden;
1238
- overflow-y: auto;
1239
- }
1240
-
1241
- .ft-filter--separator {
1242
- border-top: 1px solid ${mo.colorOutline};
1243
- margin: 4px 10px;
1244
- }
1245
-
1246
- .ft-filter--levels-container {
1247
- position: relative;
1248
- overflow: hidden;
1249
- }
1250
-
1251
- .ft-filter--levels {
1252
- position: relative;
1253
- overflow: hidden;
1254
- }
1255
-
1256
- ft-filter-level {
1257
- width: 100%;
1258
- }
1259
-
1260
- .ft-filter--level-left {
1261
- height: 0;
1262
- }
1263
-
1264
- slot {
1265
- display: none;
1266
- }
1267
- `];var wo=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};class ko extends CustomEvent{constructor(t){super("change",{detail:t})}}class Oo extends $t{constructor(){super(...arguments),this.id="",this.label="",this.filterPlaceHolder="Filter {0}",this.clearButtonLabel="Clear",this.moreValuesButtonLabel="More",this.noValuesLabel="No values available",this.options=[],this.multivalued=!1,this.disabled=!1,this.raiseSelectedOptions=!1,this.displayedValuesLimit=0,this.hideClearButton=!1,this.withScroll=!1,this.filter="",this.displayedLevels=[],this.scrollResizeObserver=new ResizeObserver((()=>this.updateScroll())),this.levelsScrollDebouncer=new e(300),this.changeDebouncer=new e(10)}get flatOptions(){return Ke(this.options,(t=>{var e;return null!==(e=t.subOptions)&&void 0!==e?e:[]}))}render(){var t,e;const i=this.flatOptions.some((t=>t.selected));let o=this.withScroll||this.filter||null!==(e=null===(t=this.lastLevel)||void 0===t?void 0:t.hasHiddenValues)&&void 0!==e&&e;return q`
1160
+ :host {
1161
+ display: flex;
1162
+ max-height: 100%;
1163
+ max-width: 100%;
1164
+ }
1165
+
1166
+ .ft-filter--container {
1167
+ flex-grow: 1;
1168
+ display: flex;
1169
+ flex-direction: column;
1170
+ max-height: 100%;
1171
+ max-width: 100%;
1172
+ color: ${mo.colorOnSurface};
1173
+ }
1174
+
1175
+ .ft-filter--header {
1176
+ display: flex;
1177
+ flex-wrap: wrap;
1178
+ gap: 4px;
1179
+ flex-shrink: 0;
1180
+ padding: 0 10px;
1181
+ margin-bottom: 8px;
1182
+ ${yt(Ut.fontSize,"14px")};
1183
+ }
1184
+
1185
+ .ft-filter--header ft-button {
1186
+ flex-shrink: 0;
1187
+ margin-left: auto;
1188
+ ${yt(Ti.iconSize,"18px")};
1189
+ }
1190
+
1191
+ .ft-filter--label {
1192
+ display: block;
1193
+ flex-shrink: 1;
1194
+ flex-grow: 1;
1195
+ word-break: break-word;
1196
+ ${yt(Ut.lineHeight,"22px")};
1197
+ ${yt(Ut.fontWeight,"bold")};
1198
+ }
1199
+
1200
+ .ft-filter--filter {
1201
+ flex-shrink: 0;
1202
+ display: flex;
1203
+ margin: 0;
1204
+ margin-bottom: 8px;
1205
+ padding: 0 10px;
1206
+ overflow: hidden;
1207
+ height: 32px;
1208
+ transition: height ${mo.transitionDuration} ${mo.transitionTimingFunction},
1209
+ margin ${mo.transitionDuration} ${mo.transitionTimingFunction};
1210
+ transition-delay: 500ms;
1211
+ }
1212
+
1213
+ .ft-filter--filter[hidden] {
1214
+ height: 0;
1215
+ margin-bottom: 0;
1216
+ }
1217
+
1218
+ input {
1219
+ display: block;
1220
+ width: 100%;
1221
+ border-radius: 4px;
1222
+ border: 1px solid ${mo.colorOutline};
1223
+ padding: 4px;
1224
+ background-color: ${mo.colorSurface};
1225
+ color: ${mo.colorOnSurface};
1226
+ outline-color: ${mo.colorPrimary};
1227
+ }
1228
+
1229
+ input::placeholder {
1230
+ color: ${mo.colorOnSurfaceMedium};
1231
+ }
1232
+
1233
+ input:placeholder-shown {
1234
+ text-overflow: ellipsis;
1235
+ }
1236
+
1237
+ .ft-filter--values {
1238
+ flex-grow: 1;
1239
+ flex-shrink: 1;
1240
+ max-width: 100%;
1241
+ overflow-x: hidden;
1242
+ overflow-y: auto;
1243
+ }
1244
+
1245
+ .ft-filter--separator {
1246
+ border-top: 1px solid ${mo.colorOutline};
1247
+ margin: 4px 10px;
1248
+ }
1249
+
1250
+ .ft-filter--levels-container {
1251
+ position: relative;
1252
+ overflow: hidden;
1253
+ }
1254
+
1255
+ .ft-filter--levels {
1256
+ position: relative;
1257
+ overflow: hidden;
1258
+ }
1259
+
1260
+ ft-filter-level {
1261
+ width: 100%;
1262
+ }
1263
+
1264
+ .ft-filter--level-left {
1265
+ height: 0;
1266
+ }
1267
+
1268
+ slot {
1269
+ display: none;
1270
+ }
1271
+ `];var wo=function(t,e,i,o){for(var s,r=arguments.length,n=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o,l=t.length-1;l>=0;l--)(s=t[l])&&(n=(r<3?s(n):r>3?s(e,i,n):s(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n};class ko extends CustomEvent{constructor(t){super("change",{detail:t})}}class Oo extends $t{constructor(){super(...arguments),this.id="",this.label="",this.filterPlaceHolder="Filter {0}",this.clearButtonLabel="Clear",this.moreValuesButtonLabel="More",this.noValuesLabel="No values available",this.options=[],this.multivalued=!1,this.disabled=!1,this.raiseSelectedOptions=!1,this.displayedValuesLimit=0,this.hideClearButton=!1,this.withScroll=!1,this.filter="",this.displayedLevels=[],this.scrollResizeObserver=new ResizeObserver((()=>this.updateScroll())),this.levelsScrollDebouncer=new e(300),this.changeDebouncer=new e(10)}get flatOptions(){return Ke(this.options,(t=>{var e;return null!==(e=t.subOptions)&&void 0!==e?e:[]}))}render(){var t,e;const i=this.flatOptions.some((t=>t.selected)),o=this.withScroll||this.filter||null!==(e=null===(t=this.lastLevel)||void 0===t?void 0:t.hasHiddenValues)&&void 0!==e&&e,s=this.filterPlaceHolder.replace("{0}",this.label);return q`
1268
1272
  <div class="ft-filter--container ${this.disabled?"ft-filter--disabled":""}"
1269
1273
  part="container">
1270
1274
  ${this.label||i?q`
@@ -1283,7 +1287,8 @@ class Ni extends qe{constructor(t){if(super(t),this.it=Y,t.type!==Ze)throw Error
1283
1287
  part="input"
1284
1288
  class="ft-typography--caption"
1285
1289
  ?disabled=${!o}
1286
- placeholder="${this.filterPlaceHolder.replace("{0}",this.label)}"
1290
+ placeholder="${s}"
1291
+ size="${o?s.length:0}"
1287
1292
  @search=${this.onFilterChange}
1288
1293
  @keyup=${this.onFilterChange}>
1289
1294
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-filter",
3
- "version": "0.3.40",
3
+ "version": "0.3.45",
4
4
  "description": "Flat selector for multivalued or monovalued filters",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,15 +19,15 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-button": "0.3.40",
23
- "@fluid-topics/ft-checkbox": "0.3.40",
24
- "@fluid-topics/ft-icon": "0.3.40",
25
- "@fluid-topics/ft-radio": "0.3.40",
26
- "@fluid-topics/ft-ripple": "0.3.40",
27
- "@fluid-topics/ft-snap-scroll": "0.3.40",
28
- "@fluid-topics/ft-typography": "0.3.40",
29
- "@fluid-topics/ft-wc-utils": "0.3.40",
22
+ "@fluid-topics/ft-button": "0.3.45",
23
+ "@fluid-topics/ft-checkbox": "0.3.45",
24
+ "@fluid-topics/ft-icon": "0.3.45",
25
+ "@fluid-topics/ft-radio": "0.3.45",
26
+ "@fluid-topics/ft-ripple": "0.3.45",
27
+ "@fluid-topics/ft-snap-scroll": "0.3.45",
28
+ "@fluid-topics/ft-typography": "0.3.45",
29
+ "@fluid-topics/ft-wc-utils": "0.3.45",
30
30
  "lit": "2.2.8"
31
31
  },
32
- "gitHead": "00f0bb16ca98f5ade4f3d9a1c3d1dce54eae97b7"
32
+ "gitHead": "92ebb6d750d61b08811c669cbf82a52c3c89b4d9"
33
33
  }