@empathyco/x-components 3.0.0-alpha.241 → 3.0.0-alpha.243
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 +30 -0
- package/design-system/default-theme.css +9 -9
- package/design-system/full-theme.css +63 -64
- package/docs/API-reference/api/x-components.searchxevents.md +1 -1
- package/docs/API-reference/api/{x-components.searchxevents.searchresponseprovided.md → x-components.searchxevents.searchresponsechanged.md} +3 -3
- package/docs/API-reference/components/history-queries/x-components.history-queries.md +9 -9
- package/docs/API-reference/components/next-queries/x-components.next-queries.md +8 -8
- package/docs/API-reference/components/popular-searches/x-components.popular-searches.md +4 -4
- package/docs/API-reference/components/query-suggestions/x-components.query-suggestions.md +19 -19
- package/js/components/highlight.vue.js +95 -0
- package/js/components/highlight.vue.js.map +1 -0
- package/js/components/highlight.vue_rollup-plugin-vue_script.vue.js +95 -0
- package/js/components/highlight.vue_rollup-plugin-vue_script.vue.js.map +1 -0
- package/js/x-modules/history-queries/components/history-queries.vue.js +15 -22
- package/js/x-modules/history-queries/components/history-queries.vue.js.map +1 -1
- package/js/x-modules/history-queries/components/history-queries.vue_rollup-plugin-vue_script.vue.js +1 -0
- package/js/x-modules/history-queries/components/history-queries.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/history-queries/store/getters/history-queries-with-results.getter.js +1 -1
- package/js/x-modules/history-queries/store/getters/history-queries-with-results.getter.js.map +1 -1
- package/js/x-modules/history-queries/wiring.js +1 -1
- package/js/x-modules/history-queries/wiring.js.map +1 -1
- package/js/x-modules/next-queries/components/next-queries.vue.js +9 -10
- package/js/x-modules/next-queries/components/next-queries.vue.js.map +1 -1
- package/js/x-modules/next-queries/components/next-queries.vue_rollup-plugin-vue_script.vue.js +1 -0
- package/js/x-modules/next-queries/components/next-queries.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/popular-searches/components/popular-searches.vue.js +9 -17
- package/js/x-modules/popular-searches/components/popular-searches.vue.js.map +1 -1
- package/js/x-modules/popular-searches/components/popular-searches.vue_rollup-plugin-vue_script.vue.js +1 -0
- package/js/x-modules/popular-searches/components/popular-searches.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestions.vue.js +9 -8
- package/js/x-modules/query-suggestions/components/query-suggestions.vue.js.map +1 -1
- package/js/x-modules/query-suggestions/components/query-suggestions.vue_rollup-plugin-vue_script.vue.js +5 -3
- package/js/x-modules/query-suggestions/components/query-suggestions.vue_rollup-plugin-vue_script.vue.js.map +1 -1
- package/js/x-modules/search/store/emitters.js +1 -1
- package/js/x-modules/search/store/emitters.js.map +1 -1
- package/package.json +2 -2
- package/report/x-components.api.json +3 -3
- package/report/x-components.api.md +3 -3
- package/types/components/highlight.vue.d.ts +86 -0
- package/types/components/highlight.vue.d.ts.map +1 -0
- package/types/x-modules/history-queries/components/history-queries.vue.d.ts.map +1 -1
- package/types/x-modules/history-queries/store/getters/history-queries-with-results.getter.d.ts.map +1 -1
- package/types/x-modules/history-queries/wiring.d.ts +1 -1
- package/types/x-modules/next-queries/components/next-queries.vue.d.ts.map +1 -1
- package/types/x-modules/popular-searches/components/popular-searches.vue.d.ts.map +1 -1
- package/types/x-modules/query-suggestions/components/query-suggestions.vue.d.ts.map +1 -1
- package/types/x-modules/search/events.types.d.ts +1 -1
- package/types/x-modules/search/events.types.d.ts.map +1 -1
- package/types/x-modules/search/store/emitters.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,36 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.0.0-alpha.243](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.242...@empathyco/x-components@3.0.0-alpha.243) (2022-12-08)
|
|
7
|
+
|
|
8
|
+
### Testing
|
|
9
|
+
|
|
10
|
+
- **e2e:** make `HistoryQueries` test wait for no results (#906)
|
|
11
|
+
([82cc3dd](https://github.com/empathyco/x/commit/82cc3ddc0f1339fbff6c04e2eff7dfbf24598672)),
|
|
12
|
+
closes [EX-7591](https://searchbroker.atlassian.net/browse/EX-7591)
|
|
13
|
+
|
|
14
|
+
# Change Log
|
|
15
|
+
|
|
16
|
+
All notable changes to this project will be documented in this file. See
|
|
17
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
18
|
+
|
|
19
|
+
## [3.0.0-alpha.242](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.241...@empathyco/x-components@3.0.0-alpha.242) (2022-12-07)
|
|
20
|
+
|
|
21
|
+
### ⚠ BREAKING CHANGES
|
|
22
|
+
|
|
23
|
+
- the event `SearchResponseProvided` was renamed to `SearchResponseChanged`
|
|
24
|
+
|
|
25
|
+
### Code Refactoring
|
|
26
|
+
|
|
27
|
+
- Simplify suggestions list slots. (#893)
|
|
28
|
+
([fc4ccb9](https://github.com/empathyco/x/commit/fc4ccb97a91b4c2ff7dfd0d7aed9747d7841b4ed)),
|
|
29
|
+
closes [EX-7469](https://searchbroker.atlassian.net/browse/EX-7469)
|
|
30
|
+
|
|
31
|
+
# Change Log
|
|
32
|
+
|
|
33
|
+
All notable changes to this project will be documented in this file. See
|
|
34
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
35
|
+
|
|
6
36
|
## [3.0.0-alpha.241](https://github.com/empathyco/x/compare/@empathyco/x-components@3.0.0-alpha.240...@empathyco/x-components@3.0.0-alpha.241) (2022-12-06)
|
|
7
37
|
|
|
8
38
|
**Note:** Version bump only for package @empathyco/x-components
|
|
@@ -734,15 +734,6 @@
|
|
|
734
734
|
stroke: none;
|
|
735
735
|
fill: var(--x-color-stroke-icon-default);
|
|
736
736
|
}
|
|
737
|
-
:root {
|
|
738
|
-
--x-color-stroke-icon-default: currentColor;
|
|
739
|
-
--x-color-fill-icon-default: none;
|
|
740
|
-
--x-size-width-icon-default: var(--x-size-width-icon-m);
|
|
741
|
-
--x-size-height-icon-default: var(--x-size-height-icon-m);
|
|
742
|
-
--x-string-stroke-linecap-icon-default: butt;
|
|
743
|
-
--x-string-stroke-linejoin-icon-default: mitter;
|
|
744
|
-
--x-size-stroke-width-icon-default: 1px;
|
|
745
|
-
}
|
|
746
737
|
:root {
|
|
747
738
|
--x-color-background-input-group-default: var(--x-color-background-input-default);
|
|
748
739
|
--x-color-border-input-group-default: var(--x-color-border-input-default);
|
|
@@ -963,6 +954,15 @@
|
|
|
963
954
|
);
|
|
964
955
|
--x-number-font-weight-input-group-default-button: var(--x-number-font-weight-base-light);
|
|
965
956
|
}
|
|
957
|
+
:root {
|
|
958
|
+
--x-color-stroke-icon-default: currentColor;
|
|
959
|
+
--x-color-fill-icon-default: none;
|
|
960
|
+
--x-size-width-icon-default: var(--x-size-width-icon-m);
|
|
961
|
+
--x-size-height-icon-default: var(--x-size-height-icon-m);
|
|
962
|
+
--x-string-stroke-linecap-icon-default: butt;
|
|
963
|
+
--x-string-stroke-linejoin-icon-default: mitter;
|
|
964
|
+
--x-size-stroke-width-icon-default: 1px;
|
|
965
|
+
}
|
|
966
966
|
:root {
|
|
967
967
|
--x-color-background-input-default: var(--x-color-base-neutral-100);
|
|
968
968
|
--x-color-border-input-default: var(--x-color-base-neutral-70);
|
|
@@ -1204,6 +1204,69 @@
|
|
|
1204
1204
|
--x-size-border-radius-bottom-right-input-card: var(--x-size-border-radius-input-card);
|
|
1205
1205
|
--x-size-border-radius-bottom-left-input-card: var(--x-size-border-radius-input-card);
|
|
1206
1206
|
}
|
|
1207
|
+
[dir="ltr"] .x-input {
|
|
1208
|
+
padding-left: var(--x-size-padding-left-input-default);
|
|
1209
|
+
}[dir="rtl"] .x-input {
|
|
1210
|
+
padding-right: var(--x-size-padding-left-input-default);
|
|
1211
|
+
}[dir="ltr"] .x-input {
|
|
1212
|
+
padding-right: var(--x-size-padding-right-input-default);
|
|
1213
|
+
}[dir="rtl"] .x-input {
|
|
1214
|
+
padding-left: var(--x-size-padding-right-input-default);
|
|
1215
|
+
}[dir="ltr"] .x-input {
|
|
1216
|
+
border-right-width: var(--x-size-border-width-right-input-default);
|
|
1217
|
+
}[dir="rtl"] .x-input {
|
|
1218
|
+
border-left-width: var(--x-size-border-width-right-input-default);
|
|
1219
|
+
}[dir="ltr"] .x-input {
|
|
1220
|
+
border-left-width: var(--x-size-border-width-left-input-default);
|
|
1221
|
+
}[dir="rtl"] .x-input {
|
|
1222
|
+
border-right-width: var(--x-size-border-width-left-input-default);
|
|
1223
|
+
}.x-input {
|
|
1224
|
+
position: relative;
|
|
1225
|
+
display: flex;
|
|
1226
|
+
overflow: hidden;
|
|
1227
|
+
box-sizing: border-box;
|
|
1228
|
+
margin: 0;
|
|
1229
|
+
min-width: 0;
|
|
1230
|
+
height: var(--x-size-height-input-default);
|
|
1231
|
+
padding-top: 0;
|
|
1232
|
+
padding-bottom: 0;
|
|
1233
|
+
background-color: var(--x-color-background-input-default);
|
|
1234
|
+
border-color: var(--x-color-border-input-default);
|
|
1235
|
+
color: var(--x-color-text-input-default);
|
|
1236
|
+
border-top-width: var(--x-size-border-width-top-input-default);
|
|
1237
|
+
border-bottom-width: var(--x-size-border-width-bottom-input-default);
|
|
1238
|
+
border-radius: var(--x-size-border-radius-top-left-input-default) var(--x-size-border-radius-top-right-input-default) var(--x-size-border-radius-bottom-right-input-default) var(--x-size-border-radius-bottom-left-input-default);
|
|
1239
|
+
border-style: solid;
|
|
1240
|
+
font-family: var(--x-font-family-input-default);
|
|
1241
|
+
font-size: var(--x-size-font-input-default);
|
|
1242
|
+
font-weight: var(--x-number-font-weight-input-default);
|
|
1243
|
+
line-height: var(--x-size-line-height-input-default);
|
|
1244
|
+
}
|
|
1245
|
+
@media not all and (-webkit-min-device-pixel-ratio: 0), not all and (min-resolution: 0.001dpcm) {
|
|
1246
|
+
.x-input {
|
|
1247
|
+
-webkit-appearance: none;
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
.x-input:focus {
|
|
1251
|
+
border-color: var(--x-color-border-input-default-focus);
|
|
1252
|
+
}
|
|
1253
|
+
.x-input > .x-input-placeholder {
|
|
1254
|
+
position: absolute;
|
|
1255
|
+
height: 100%;
|
|
1256
|
+
}
|
|
1257
|
+
.x-input > .x-input {
|
|
1258
|
+
background: none;
|
|
1259
|
+
border: none;
|
|
1260
|
+
padding: 0;
|
|
1261
|
+
flex: 1 1 auto;
|
|
1262
|
+
}
|
|
1263
|
+
.x-input > .x-input-placeholder, .x-input::placeholder {
|
|
1264
|
+
color: var(--x-color-text-input-placeholder-default);
|
|
1265
|
+
font-family: var(--x-font-family-input-placeholder-default);
|
|
1266
|
+
font-size: var(--x-size-font-input-placeholder-default);
|
|
1267
|
+
font-weight: var(--x-number-font-weight-input-placeholder-default);
|
|
1268
|
+
line-height: var(--x-size-line-height-input-placeholder-default);
|
|
1269
|
+
}
|
|
1207
1270
|
:root {
|
|
1208
1271
|
--x-color-background-input-default: var(--x-color-base-neutral-100);
|
|
1209
1272
|
--x-color-border-input-default: var(--x-color-base-neutral-70);
|
|
@@ -7173,67 +7236,3 @@
|
|
|
7173
7236
|
.x-normal-case {
|
|
7174
7237
|
text-transform: none;
|
|
7175
7238
|
}
|
|
7176
|
-
|
|
7177
|
-
[dir="ltr"] .x-input {
|
|
7178
|
-
padding-left: var(--x-size-padding-left-input-default);
|
|
7179
|
-
}[dir="rtl"] .x-input {
|
|
7180
|
-
padding-right: var(--x-size-padding-left-input-default);
|
|
7181
|
-
}[dir="ltr"] .x-input {
|
|
7182
|
-
padding-right: var(--x-size-padding-right-input-default);
|
|
7183
|
-
}[dir="rtl"] .x-input {
|
|
7184
|
-
padding-left: var(--x-size-padding-right-input-default);
|
|
7185
|
-
}[dir="ltr"] .x-input {
|
|
7186
|
-
border-right-width: var(--x-size-border-width-right-input-default);
|
|
7187
|
-
}[dir="rtl"] .x-input {
|
|
7188
|
-
border-left-width: var(--x-size-border-width-right-input-default);
|
|
7189
|
-
}[dir="ltr"] .x-input {
|
|
7190
|
-
border-left-width: var(--x-size-border-width-left-input-default);
|
|
7191
|
-
}[dir="rtl"] .x-input {
|
|
7192
|
-
border-right-width: var(--x-size-border-width-left-input-default);
|
|
7193
|
-
}.x-input {
|
|
7194
|
-
position: relative;
|
|
7195
|
-
display: flex;
|
|
7196
|
-
overflow: hidden;
|
|
7197
|
-
box-sizing: border-box;
|
|
7198
|
-
margin: 0;
|
|
7199
|
-
min-width: 0;
|
|
7200
|
-
height: var(--x-size-height-input-default);
|
|
7201
|
-
padding-top: 0;
|
|
7202
|
-
padding-bottom: 0;
|
|
7203
|
-
background-color: var(--x-color-background-input-default);
|
|
7204
|
-
border-color: var(--x-color-border-input-default);
|
|
7205
|
-
color: var(--x-color-text-input-default);
|
|
7206
|
-
border-top-width: var(--x-size-border-width-top-input-default);
|
|
7207
|
-
border-bottom-width: var(--x-size-border-width-bottom-input-default);
|
|
7208
|
-
border-radius: var(--x-size-border-radius-top-left-input-default) var(--x-size-border-radius-top-right-input-default) var(--x-size-border-radius-bottom-right-input-default) var(--x-size-border-radius-bottom-left-input-default);
|
|
7209
|
-
border-style: solid;
|
|
7210
|
-
font-family: var(--x-font-family-input-default);
|
|
7211
|
-
font-size: var(--x-size-font-input-default);
|
|
7212
|
-
font-weight: var(--x-number-font-weight-input-default);
|
|
7213
|
-
line-height: var(--x-size-line-height-input-default);
|
|
7214
|
-
}
|
|
7215
|
-
@media not all and (-webkit-min-device-pixel-ratio: 0), not all and (min-resolution: 0.001dpcm) {
|
|
7216
|
-
.x-input {
|
|
7217
|
-
-webkit-appearance: none;
|
|
7218
|
-
}
|
|
7219
|
-
}
|
|
7220
|
-
.x-input:focus {
|
|
7221
|
-
border-color: var(--x-color-border-input-default-focus);
|
|
7222
|
-
}
|
|
7223
|
-
.x-input > .x-input-placeholder {
|
|
7224
|
-
position: absolute;
|
|
7225
|
-
height: 100%;
|
|
7226
|
-
}
|
|
7227
|
-
.x-input > .x-input {
|
|
7228
|
-
background: none;
|
|
7229
|
-
border: none;
|
|
7230
|
-
padding: 0;
|
|
7231
|
-
flex: 1 1 auto;
|
|
7232
|
-
}
|
|
7233
|
-
.x-input > .x-input-placeholder, .x-input::placeholder {
|
|
7234
|
-
color: var(--x-color-text-input-placeholder-default);
|
|
7235
|
-
font-family: var(--x-font-family-input-placeholder-default);
|
|
7236
|
-
font-size: var(--x-size-font-input-placeholder-default);
|
|
7237
|
-
font-weight: var(--x-number-font-weight-input-placeholder-default);
|
|
7238
|
-
line-height: var(--x-size-line-height-input-placeholder-default);
|
|
7239
|
-
}
|
|
@@ -21,7 +21,7 @@ export interface SearchXEvents
|
|
|
21
21
|
| [ResultsChanged](./x-components.searchxevents.resultschanged.md) | Result\[\] | Results have been changed. Payload: The new [results](./x-types.result.md)<!-- -->. |
|
|
22
22
|
| [SearchRequestChanged](./x-components.searchxevents.searchrequestchanged.md) | [InternalSearchRequest](./x-components.internalsearchrequest.md) \| null | Any property of the search request has changed. Payload: The new search request or <code>null</code> if there is not enough data in the state to conform a valid request. |
|
|
23
23
|
| [SearchRequestUpdated](./x-components.searchxevents.searchrequestupdated.md) | [InternalSearchRequest](./x-components.internalsearchrequest.md) | Any property of the search request has been updated. Payload: The new internal request object. |
|
|
24
|
-
| [
|
|
24
|
+
| [SearchResponseChanged](./x-components.searchxevents.searchresponsechanged.md) | [InternalSearchResponse](./x-components.internalsearchresponse.md) | A search response has been provided. Payload: The provided internal response object. |
|
|
25
25
|
| [SearchTaggingChanged](./x-components.searchxevents.searchtaggingchanged.md) | TaggingRequest | Query tagging has been changed. Payload: The new query tagging object. |
|
|
26
26
|
| [SelectedSortProvided](./x-components.searchxevents.selectedsortprovided.md) | Sort | A new selected sort has been provided. Payload: The sort option that has been provided. |
|
|
27
27
|
| [SortChanged](./x-components.searchxevents.sortchanged.md) | string | Sort has been changed. Payload: The new sort string. |
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
2
|
|
|
3
|
-
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [SearchXEvents](./x-components.searchxevents.md) > [
|
|
3
|
+
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [SearchXEvents](./x-components.searchxevents.md) > [SearchResponseChanged](./x-components.searchxevents.searchresponsechanged.md)
|
|
4
4
|
|
|
5
|
-
## SearchXEvents.
|
|
5
|
+
## SearchXEvents.SearchResponseChanged property
|
|
6
6
|
|
|
7
7
|
A search response has been provided. Payload: The provided internal response object.
|
|
8
8
|
|
|
9
9
|
<b>Signature:</b>
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
|
|
12
|
+
SearchResponseChanged: InternalSearchResponse;
|
|
13
13
|
```
|
|
@@ -12,21 +12,21 @@ another type of suggestion that contains a query that the user has made in the p
|
|
|
12
12
|
|
|
13
13
|
## Slots
|
|
14
14
|
|
|
15
|
-
| Name | Description | Bindings<br />(name - type - description)
|
|
16
|
-
| -------------------------------------- | ----------------------------------- |
|
|
17
|
-
| <code>suggestion</code> | History Query item | **v-bind** <code>Object</code> - History Query suggestion attributes:<br /> - **suggestion** <code>Suggestion</code> - History Query suggestion data<br /> - **index** <code>number</code> - History Query suggestion index
|
|
18
|
-
| <code>suggestion-content</code> | History Query content | **
|
|
19
|
-
| <code>suggestion-remove-content</code> | History Query remove button content | **v-bind** <code>Object</code> - History Query suggestion attributes:<br /> - **suggestion** <code>Suggestion</code> - History Query suggestion data<br /> - **index** <code>number</code> - History Query suggestion index
|
|
15
|
+
| Name | Description | Bindings<br />(name - type - description) |
|
|
16
|
+
| -------------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
17
|
+
| <code>suggestion</code> | History Query item | **v-bind** <code>Object</code> - History Query suggestion attributes:<br /> - **suggestion** <code>Suggestion</code> - History Query suggestion data<br /> - **index** <code>number</code> - History Query suggestion index |
|
|
18
|
+
| <code>suggestion-content</code> | History Query content | **v-bind** <code>Object</code> - History Query suggestion attributes:<br /> - **suggestion** <code>Suggestion</code> - History Query suggestion data<br /> - **index** <code>number</code> - History Query suggestion index |
|
|
19
|
+
| <code>suggestion-remove-content</code> | History Query remove button content | **v-bind** <code>Object</code> - History Query suggestion attributes:<br /> - **suggestion** <code>Suggestion</code> - History Query suggestion data<br /> - **index** <code>number</code> - History Query suggestion index |
|
|
20
20
|
|
|
21
21
|
## Inherited props
|
|
22
22
|
|
|
23
23
|
This component inherits the [`BaseSuggestions`](../base-components/x-components.base-suggestions.md)
|
|
24
24
|
props.
|
|
25
25
|
|
|
26
|
-
| Name
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
26
|
+
| Name | Description | Type | Default |
|
|
27
|
+
| ------------------ | ----------------------------------------------------------------- | -------- | ------- |
|
|
28
|
+
| `animation` | Animation component that will be used to animate the suggestions. | `Vue` | `"ul"` |
|
|
29
|
+
| `maxItemsToRender` | Number of popular searches to be rendered. | `number` | |
|
|
30
30
|
|
|
31
31
|
## Events
|
|
32
32
|
|
|
@@ -21,20 +21,20 @@ for `shirts`, and then `trousers`, `trousers` would be a next query of `shirts`.
|
|
|
21
21
|
|
|
22
22
|
## Slots
|
|
23
23
|
|
|
24
|
-
| Name | Description | Bindings<br />(name - type - description)
|
|
25
|
-
| ------------------------------- | ------------------ |
|
|
26
|
-
| <code>suggestion</code> | Next Query item | **highlightCurated** <code>boolean</code> - True if the curated NQs should be highlighted<br />**v-bind** <code>Object</code> - Next Query suggestion attributes:<br /> - **suggestion** <code>Suggestion</code> - Next Query suggestion data<br /> - **index** <code>number</code> - Next Query suggestion index
|
|
27
|
-
| <code>suggestion-content</code> | Next Query content | **
|
|
24
|
+
| Name | Description | Bindings<br />(name - type - description) |
|
|
25
|
+
| ------------------------------- | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
26
|
+
| <code>suggestion</code> | Next Query item | **highlightCurated** <code>boolean</code> - True if the curated NQs should be highlighted<br />**v-bind** <code>Object</code> - Next Query suggestion attributes:<br /> - **suggestion** <code>Suggestion</code> - Next Query suggestion data<br /> - **index** <code>number</code> - Next Query suggestion index |
|
|
27
|
+
| <code>suggestion-content</code> | Next Query content | **v-bind** <code>Object</code> - Next Query suggestion attributes:<br /> - **suggestion** <code>Suggestion</code> - Next Query suggestion data<br /> - **index** <code>number</code> - Next Query suggestion index |
|
|
28
28
|
|
|
29
29
|
## Inherited props
|
|
30
30
|
|
|
31
31
|
This component inherits the [`BaseSuggestions`](../base-components/x-components.base-suggestions.md)
|
|
32
32
|
props.
|
|
33
33
|
|
|
34
|
-
| Name
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
34
|
+
| Name | Description | Type | Default |
|
|
35
|
+
| ------------------ | ----------------------------------------------------------------- | -------- | ------- |
|
|
36
|
+
| `animation` | Animation component that will be used to animate the suggestions. | `Vue` | `"ul"` |
|
|
37
|
+
| `maxItemsToRender` | Number of popular searches to be rendered. | `number` | |
|
|
38
38
|
|
|
39
39
|
## Examples
|
|
40
40
|
|
|
@@ -23,10 +23,10 @@ optionally have associated a set of filters.
|
|
|
23
23
|
This component inherits the [`BaseSuggestions`](../base-components/x-components.base-suggestions.md)
|
|
24
24
|
props.
|
|
25
25
|
|
|
26
|
-
| Name
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
26
|
+
| Name | Description | Type | Default |
|
|
27
|
+
| ------------------ | ----------------------------------------------------------------- | -------- | ------- |
|
|
28
|
+
| `animation` | Animation component that will be used to animate the suggestions. | `Vue` | `"ul"` |
|
|
29
|
+
| `maxItemsToRender` | Number of popular searches to be rendered. | `number` | |
|
|
30
30
|
|
|
31
31
|
## Examples
|
|
32
32
|
|
|
@@ -12,20 +12,20 @@ in the input field. By default, this is a list of
|
|
|
12
12
|
|
|
13
13
|
## Slots
|
|
14
14
|
|
|
15
|
-
| Name | Description | Bindings<br />(name - type - description)
|
|
16
|
-
| ------------------------------- | ------------------------------------------------------------------ |
|
|
17
|
-
| <code>suggestion</code> | Custom component that replaces the `QuerySuggestion` component | **v-bind** <code>Object</code> - Query Suggestion attributes:<br /> - **suggestion**
|
|
18
|
-
| <code>suggestion-content</code> | Custom content that replaces the `QuerySuggestion` default content | **
|
|
15
|
+
| Name | Description | Bindings<br />(name - type - description) |
|
|
16
|
+
| ------------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
17
|
+
| <code>suggestion</code> | Custom component that replaces the `QuerySuggestion` component | **v-bind** <code>Object</code> - Query Suggestion attributes:<br /> - **suggestion** `Suggestion` - Query Suggestion data<br /> - **index** `number` - Query Suggestion index |
|
|
18
|
+
| <code>suggestion-content</code> | Custom content that replaces the `QuerySuggestion` default content | **v-bind** <code>Object</code> - Query Suggestion attributes:<br /> - **suggestion** `Suggestion` - Query Suggestion data<br /> - **index** `number` - Query Suggestion index |
|
|
19
19
|
|
|
20
20
|
## Inherited props
|
|
21
21
|
|
|
22
22
|
This component inherits the [`BaseSuggestions`](../base-components/x-components.base-suggestions.md)
|
|
23
23
|
props.
|
|
24
24
|
|
|
25
|
-
| Name
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
25
|
+
| Name | Description | Type | Default |
|
|
26
|
+
| ------------------ | ------------------------------------------- | -------- | ------- |
|
|
27
|
+
| `animation` | Animation component for `QuerySuggestions`. | `Vue` | `"ul"` |
|
|
28
|
+
| `maxItemsToRender` | Number of query suggestions to be rendered. | `number` | |
|
|
29
29
|
|
|
30
30
|
## See it in action
|
|
31
31
|
|
|
@@ -108,8 +108,9 @@ _Type “bag” or another fashion term in the input field to try it out!_
|
|
|
108
108
|
<div>
|
|
109
109
|
<SearchInput />
|
|
110
110
|
<QuerySuggestions #suggestion="{ suggestion }">
|
|
111
|
-
<QuerySuggestion :suggestion="suggestion" #default="{
|
|
112
|
-
<span
|
|
111
|
+
<QuerySuggestion :suggestion="suggestion" #default="{ suggestion }">
|
|
112
|
+
<span>🔍</span>
|
|
113
|
+
<span>{{ suggestion.query }}</span>
|
|
113
114
|
</QuerySuggestion>
|
|
114
115
|
</QuerySuggestions>
|
|
115
116
|
</div>
|
|
@@ -181,8 +182,8 @@ you must implement the `UserAcceptedAQuery` and `UserSelectedAQuerySuggestion` e
|
|
|
181
182
|
|
|
182
183
|
### Play with suggestion-content slot
|
|
183
184
|
|
|
184
|
-
In this example, the `suggestion` and `
|
|
185
|
-
|
|
185
|
+
In this example, the `suggestion` and `query` properties of the `suggestion-content` slot are used
|
|
186
|
+
to paint a suggestion with an icon.
|
|
186
187
|
|
|
187
188
|
_Type “trousers” or another toy in the input field to try it out!_
|
|
188
189
|
|
|
@@ -190,12 +191,9 @@ _Type “trousers” or another toy in the input field to try it out!_
|
|
|
190
191
|
<template>
|
|
191
192
|
<div>
|
|
192
193
|
<SearchInput />
|
|
193
|
-
<QuerySuggestions #suggestion-content="{ suggestion,
|
|
194
|
-
<span
|
|
195
|
-
|
|
196
|
-
style="color: blue;"
|
|
197
|
-
v-html="queryHTML"
|
|
198
|
-
/>
|
|
194
|
+
<QuerySuggestions #suggestion-content="{ suggestion, query }">
|
|
195
|
+
<span>🔍</span>
|
|
196
|
+
<Highlight :text="suggestion.query" :highlight="query" />
|
|
199
197
|
</QuerySuggestions>
|
|
200
198
|
</div>
|
|
201
199
|
</template>
|
|
@@ -203,12 +201,14 @@ _Type “trousers” or another toy in the input field to try it out!_
|
|
|
203
201
|
<script>
|
|
204
202
|
import { QuerySuggestions } from "@empathyco/x-components/query-suggestions";
|
|
205
203
|
import { SearchInput } from "@empathyco/x-components/search-box";
|
|
204
|
+
import { Highlight } from "@empathyco/x-components";
|
|
206
205
|
|
|
207
206
|
export default {
|
|
208
207
|
name: "QuerySuggestionsDemo",
|
|
209
208
|
components: {
|
|
210
209
|
SearchInput,
|
|
211
|
-
QuerySuggestions
|
|
210
|
+
QuerySuggestions,
|
|
211
|
+
Highlight
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
</script>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import script from './highlight.vue_rollup-plugin-vue_script.vue.js';
|
|
2
|
+
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.mjs';
|
|
3
|
+
|
|
4
|
+
/* script */
|
|
5
|
+
const __vue_script__ = script;
|
|
6
|
+
|
|
7
|
+
/* template */
|
|
8
|
+
var __vue_render__ = function () {
|
|
9
|
+
var _vm = this;
|
|
10
|
+
var _h = _vm.$createElement;
|
|
11
|
+
var _c = _vm._self._c || _h;
|
|
12
|
+
return _c(
|
|
13
|
+
"NoElement",
|
|
14
|
+
[
|
|
15
|
+
_vm._t(
|
|
16
|
+
"default",
|
|
17
|
+
function () {
|
|
18
|
+
return [
|
|
19
|
+
_c(
|
|
20
|
+
"span",
|
|
21
|
+
{ staticClass: "x-highlight", class: _vm.dynamicCSSClasses },
|
|
22
|
+
[
|
|
23
|
+
_vm.matchParts.start
|
|
24
|
+
? _c("span", {
|
|
25
|
+
staticClass: "x-highlight__text",
|
|
26
|
+
attrs: { "data-test": "highlight-start" },
|
|
27
|
+
domProps: { textContent: _vm._s(_vm.matchParts.start) },
|
|
28
|
+
})
|
|
29
|
+
: _vm._e(),
|
|
30
|
+
_vm._v(" "),
|
|
31
|
+
_vm.hasMatch
|
|
32
|
+
? _c("span", {
|
|
33
|
+
staticClass: "x-highlight__text x-highlight-text-match",
|
|
34
|
+
class: _vm.matchingPartClass,
|
|
35
|
+
attrs: { "data-test": "matching-part" },
|
|
36
|
+
domProps: { textContent: _vm._s(_vm.matchParts.match) },
|
|
37
|
+
})
|
|
38
|
+
: _vm._e(),
|
|
39
|
+
_vm._v(" "),
|
|
40
|
+
_vm.matchParts.end
|
|
41
|
+
? _c("span", {
|
|
42
|
+
staticClass: "x-highlight__text",
|
|
43
|
+
attrs: { "data-test": "highlight-end" },
|
|
44
|
+
domProps: { textContent: _vm._s(_vm.matchParts.end) },
|
|
45
|
+
})
|
|
46
|
+
: _vm._e(),
|
|
47
|
+
]
|
|
48
|
+
),
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
null,
|
|
52
|
+
Object.assign(
|
|
53
|
+
{},
|
|
54
|
+
{ text: _vm.text, hasMatch: _vm.hasMatch },
|
|
55
|
+
_vm.matchParts
|
|
56
|
+
)
|
|
57
|
+
),
|
|
58
|
+
],
|
|
59
|
+
2
|
|
60
|
+
)
|
|
61
|
+
};
|
|
62
|
+
var __vue_staticRenderFns__ = [];
|
|
63
|
+
__vue_render__._withStripped = true;
|
|
64
|
+
|
|
65
|
+
/* style */
|
|
66
|
+
const __vue_inject_styles__ = undefined;
|
|
67
|
+
/* scoped */
|
|
68
|
+
const __vue_scope_id__ = undefined;
|
|
69
|
+
/* module identifier */
|
|
70
|
+
const __vue_module_identifier__ = undefined;
|
|
71
|
+
/* functional template */
|
|
72
|
+
const __vue_is_functional_template__ = false;
|
|
73
|
+
/* style inject */
|
|
74
|
+
|
|
75
|
+
/* style inject SSR */
|
|
76
|
+
|
|
77
|
+
/* style inject shadow dom */
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
const __vue_component__ = /*#__PURE__*/__vue_normalize__(
|
|
82
|
+
{ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
|
|
83
|
+
__vue_inject_styles__,
|
|
84
|
+
__vue_script__,
|
|
85
|
+
__vue_scope_id__,
|
|
86
|
+
__vue_is_functional_template__,
|
|
87
|
+
__vue_module_identifier__,
|
|
88
|
+
false,
|
|
89
|
+
undefined,
|
|
90
|
+
undefined,
|
|
91
|
+
undefined
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
export { __vue_component__ as default };
|
|
95
|
+
//# sourceMappingURL=highlight.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.vue.js","sources":["../../../src/components/highlight.vue"],"sourcesContent":["<template>\n <NoElement>\n <slot v-bind=\"{ text, hasMatch, ...matchParts }\">\n <span class=\"x-highlight\" :class=\"dynamicCSSClasses\">\n <span\n v-if=\"matchParts.start\"\n v-text=\"matchParts.start\"\n class=\"x-highlight__text\"\n data-test=\"highlight-start\"\n />\n <span\n v-if=\"hasMatch\"\n v-text=\"matchParts.match\"\n class=\"x-highlight__text x-highlight-text-match\"\n :class=\"matchingPartClass\"\n data-test=\"matching-part\"\n />\n <span\n v-if=\"matchParts.end\"\n v-text=\"matchParts.end\"\n class=\"x-highlight__text\"\n data-test=\"highlight-end\"\n />\n </span>\n </slot>\n </NoElement>\n</template>\n\n<script lang=\"ts\">\n import { Component, Mixins, Prop } from 'vue-property-decorator';\n import { normalizeString } from '../utils/normalize';\n import { VueCSSClasses } from '../utils/types';\n import { NoElement } from './no-element';\n import { dynamicPropsMixin } from './dynamic-props.mixin';\n\n /**\n * Highlights the given part of the text. The component is smart enough to do matches\n * between special characters like tilde, cedilla, eñe, capital letters...\n *\n * @public\n */\n @Component({\n components: { NoElement }\n })\n export default class Highlight extends Mixins(\n dynamicPropsMixin(['noMatchClass', 'matchingPartClass'])\n ) {\n /**\n * The text to highlight some part of it.\n *\n * @public\n */\n @Prop({ default: '' })\n public text!: string;\n\n /**\n * The part of the text to be highlighted.\n *\n * @public\n */\n @Prop({ default: '' })\n public highlight!: string;\n\n /**\n * CSS Class to add when the `text` string contains the `highlight` string.\n */\n @Prop({ default: '' })\n public matchClass!: string;\n\n /**\n * Checks if the normalized suggestion query matches with the module's query, so it has a\n * matching part.\n *\n * @returns True if there is a match between the text and the highlight strings.\n * @internal\n */\n protected get hasMatch(): boolean {\n return !!this.matchParts.match;\n }\n\n /**\n * CSS classes to add depending on the component state.\n *\n * @remarks\n * `x-highlight--has-match`: When there is a match between the text and the part to highlight.\n * `[matchClass]`: When there is a match between the text and\n * the part to highlight.\n * `[noMatchClass]`: when there is no match between the text to highlight.\n * @returns The {@link VueCSSClasses} classes.\n * @internal\n */\n protected get dynamicCSSClasses(): VueCSSClasses {\n const classes: VueCSSClasses = {\n 'x-highlight--has-match': this.hasMatch,\n 'x-highlight-text': this.hasMatch,\n [this.matchClass]: this.hasMatch\n };\n if (this.noMatchClass) {\n classes[this.noMatchClass] = !this.hasMatch;\n }\n return classes;\n }\n\n /**\n * Splits the text to highlight into 3 parts: a starting part, the matching part\n * and the ending part. If there is no match between the text and the highlight, the `start`\n * property will contain the whole text.\n *\n * @returns An object containing the different parts of the text.\n * @internal\n */\n protected get matchParts(): HighlightMatch {\n const matcherIndex = normalizeString(this.text).indexOf(normalizeString(this.highlight));\n return matcherIndex !== -1 && this.highlight\n ? this.splitAt(this.text.trim(), matcherIndex, matcherIndex + this.highlight.trim().length)\n : { start: this.text, match: '', end: '' };\n }\n\n /**\n * Splits the label in three parts based on two indexes.\n *\n * @param label - The string that will be divided in three parts.\n * @param start - The first index that the label will be divided by.\n * @param end - The second index that the label will be divided by.\n *\n * @returns The three parts of the divided label.\n * @internal\n */\n protected splitAt(label: string, start: number, end: number): HighlightMatch {\n return {\n start: label.substring(0, start),\n match: label.substring(start, end),\n end: label.substring(end)\n };\n }\n }\n\n /**\n * Contains the different parts of a string match.\n */\n interface HighlightMatch {\n /**\n * When the match does not happen from the beginning of the string, the initial unmatched\n * part.\n */\n start: string;\n /**\n * The part of the text that is matching.\n */\n match: string;\n /**\n * When the match does not extend until the end, the remaining unmatched string.\n */\n end: string;\n }\n</script>\n\n<docs lang=\"mdx\">\n## Events\n\nThis component emits no events.\n\n## See it in action\n\nHere you have a basic example of how the highlight component is rendered.\n\n_Type any term in the input field to try it out!_\n\n```vue live\n<template>\n <div>\n <input v-model=\"highlight\" />\n <Highlight :highlight=\"highlight\" text=\"milanesa\" />\n </div>\n</template>\n\n<script>\n import { Highlight } from '@empathyco/x-components';\n\n export default {\n name: 'HighlightDemo',\n components: {\n Highlight\n },\n data() {\n return {\n highlight: ''\n };\n }\n };\n</script>\n```\n\n### Customise the layout\n\nThis component allows to customise the whole layout. Be careful as due to Vue 2 limitations you can\nonly render a single root element.\n\n```vue live\n<template>\n <div>\n <input v-model=\"highlight\" />\n <Highlight\n :highlight=\"highlight\"\n text=\"Entraña\"\n #default=\"{ hasMatch, start, match, end, text }\"\n >\n <span class=\"custom-layout\" v-if=\"hasMatch\">\n <strong>{{ start }}</strong>\n {{ match }}\n <strong>{{ end }}</strong>\n </span>\n <span v-else>{{ text }}</span>\n </Highlight>\n </div>\n</template>\n\n<script>\n import { Highlight } from '@empathyco/x-components';\n\n export default {\n name: 'HighlightDemo',\n components: {\n Highlight\n },\n data() {\n return {\n highlight: 'entran'\n };\n }\n };\n</script>\n```\n</docs>\n"],"names":[],"mappings":";;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { __decorate } from 'tslib';
|
|
2
|
+
import { Mixins, Prop, Component } from 'vue-property-decorator';
|
|
3
|
+
import { normalizeString } from '../utils/normalize.js';
|
|
4
|
+
import { NoElement } from './no-element.js';
|
|
5
|
+
import { dynamicPropsMixin } from './dynamic-props.mixin.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Highlights the given part of the text. The component is smart enough to do matches
|
|
9
|
+
* between special characters like tilde, cedilla, eñe, capital letters...
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
let Highlight = class Highlight extends Mixins(dynamicPropsMixin(['noMatchClass', 'matchingPartClass'])) {
|
|
14
|
+
/**
|
|
15
|
+
* Checks if the normalized suggestion query matches with the module's query, so it has a
|
|
16
|
+
* matching part.
|
|
17
|
+
*
|
|
18
|
+
* @returns True if there is a match between the text and the highlight strings.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
get hasMatch() {
|
|
22
|
+
return !!this.matchParts.match;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* CSS classes to add depending on the component state.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* `x-highlight--has-match`: When there is a match between the text and the part to highlight.
|
|
29
|
+
* `[matchClass]`: When there is a match between the text and
|
|
30
|
+
* the part to highlight.
|
|
31
|
+
* `[noMatchClass]`: when there is no match between the text to highlight.
|
|
32
|
+
* @returns The {@link VueCSSClasses} classes.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
get dynamicCSSClasses() {
|
|
36
|
+
const classes = {
|
|
37
|
+
'x-highlight--has-match': this.hasMatch,
|
|
38
|
+
'x-highlight-text': this.hasMatch,
|
|
39
|
+
[this.matchClass]: this.hasMatch
|
|
40
|
+
};
|
|
41
|
+
if (this.noMatchClass) {
|
|
42
|
+
classes[this.noMatchClass] = !this.hasMatch;
|
|
43
|
+
}
|
|
44
|
+
return classes;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Splits the text to highlight into 3 parts: a starting part, the matching part
|
|
48
|
+
* and the ending part. If there is no match between the text and the highlight, the `start`
|
|
49
|
+
* property will contain the whole text.
|
|
50
|
+
*
|
|
51
|
+
* @returns An object containing the different parts of the text.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
get matchParts() {
|
|
55
|
+
const matcherIndex = normalizeString(this.text).indexOf(normalizeString(this.highlight));
|
|
56
|
+
return matcherIndex !== -1 && this.highlight
|
|
57
|
+
? this.splitAt(this.text.trim(), matcherIndex, matcherIndex + this.highlight.trim().length)
|
|
58
|
+
: { start: this.text, match: '', end: '' };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Splits the label in three parts based on two indexes.
|
|
62
|
+
*
|
|
63
|
+
* @param label - The string that will be divided in three parts.
|
|
64
|
+
* @param start - The first index that the label will be divided by.
|
|
65
|
+
* @param end - The second index that the label will be divided by.
|
|
66
|
+
*
|
|
67
|
+
* @returns The three parts of the divided label.
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
splitAt(label, start, end) {
|
|
71
|
+
return {
|
|
72
|
+
start: label.substring(0, start),
|
|
73
|
+
match: label.substring(start, end),
|
|
74
|
+
end: label.substring(end)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
__decorate([
|
|
79
|
+
Prop({ default: '' })
|
|
80
|
+
], Highlight.prototype, "text", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
Prop({ default: '' })
|
|
83
|
+
], Highlight.prototype, "highlight", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
Prop({ default: '' })
|
|
86
|
+
], Highlight.prototype, "matchClass", void 0);
|
|
87
|
+
Highlight = __decorate([
|
|
88
|
+
Component({
|
|
89
|
+
components: { NoElement }
|
|
90
|
+
})
|
|
91
|
+
], Highlight);
|
|
92
|
+
var script = Highlight;
|
|
93
|
+
|
|
94
|
+
export { script as default };
|
|
95
|
+
//# sourceMappingURL=highlight.vue_rollup-plugin-vue_script.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.vue_rollup-plugin-vue_script.vue.js","sources":["../../../src/components/highlight.vue?rollup-plugin-vue=script.ts"],"sourcesContent":["\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nimport { Component, Mixins, Prop } from 'vue-property-decorator';\nimport { normalizeString } from '../utils/normalize';\nimport { VueCSSClasses } from '../utils/types';\nimport { NoElement } from './no-element';\nimport { dynamicPropsMixin } from './dynamic-props.mixin';\n\n/**\n * Highlights the given part of the text. The component is smart enough to do matches\n * between special characters like tilde, cedilla, eñe, capital letters...\n *\n * @public\n */\n@Component({\n components: { NoElement }\n})\nexport default class Highlight extends Mixins(\n dynamicPropsMixin(['noMatchClass', 'matchingPartClass'])\n) {\n /**\n * The text to highlight some part of it.\n *\n * @public\n */\n @Prop({ default: '' })\n public text!: string;\n\n /**\n * The part of the text to be highlighted.\n *\n * @public\n */\n @Prop({ default: '' })\n public highlight!: string;\n\n /**\n * CSS Class to add when the `text` string contains the `highlight` string.\n */\n @Prop({ default: '' })\n public matchClass!: string;\n\n /**\n * Checks if the normalized suggestion query matches with the module's query, so it has a\n * matching part.\n *\n * @returns True if there is a match between the text and the highlight strings.\n * @internal\n */\n protected get hasMatch(): boolean {\n return !!this.matchParts.match;\n }\n\n /**\n * CSS classes to add depending on the component state.\n *\n * @remarks\n * `x-highlight--has-match`: When there is a match between the text and the part to highlight.\n * `[matchClass]`: When there is a match between the text and\n * the part to highlight.\n * `[noMatchClass]`: when there is no match between the text to highlight.\n * @returns The {@link VueCSSClasses} classes.\n * @internal\n */\n protected get dynamicCSSClasses(): VueCSSClasses {\n const classes: VueCSSClasses = {\n 'x-highlight--has-match': this.hasMatch,\n 'x-highlight-text': this.hasMatch,\n [this.matchClass]: this.hasMatch\n };\n if (this.noMatchClass) {\n classes[this.noMatchClass] = !this.hasMatch;\n }\n return classes;\n }\n\n /**\n * Splits the text to highlight into 3 parts: a starting part, the matching part\n * and the ending part. If there is no match between the text and the highlight, the `start`\n * property will contain the whole text.\n *\n * @returns An object containing the different parts of the text.\n * @internal\n */\n protected get matchParts(): HighlightMatch {\n const matcherIndex = normalizeString(this.text).indexOf(normalizeString(this.highlight));\n return matcherIndex !== -1 && this.highlight\n ? this.splitAt(this.text.trim(), matcherIndex, matcherIndex + this.highlight.trim().length)\n : { start: this.text, match: '', end: '' };\n }\n\n /**\n * Splits the label in three parts based on two indexes.\n *\n * @param label - The string that will be divided in three parts.\n * @param start - The first index that the label will be divided by.\n * @param end - The second index that the label will be divided by.\n *\n * @returns The three parts of the divided label.\n * @internal\n */\n protected splitAt(label: string, start: number, end: number): HighlightMatch {\n return {\n start: label.substring(0, start),\n match: label.substring(start, end),\n end: label.substring(end)\n };\n }\n}\n\n/**\n * Contains the different parts of a string match.\n */\ninterface HighlightMatch {\n /**\n * When the match does not happen from the beginning of the string, the initial unmatched\n * part.\n */\n start: string;\n /**\n * The part of the text that is matching.\n */\n match: string;\n /**\n * When the match does not extend until the end, the remaining unmatched string.\n */\n end: string;\n}\n"],"names":[],"mappings":";;;;;;AAmCA;;;;;;AASA,IAAqB,SAAS,GAA9B,MAAqB,SAAU,SAAQ,MAAM,CAC3C,iBAAiB,CAAC,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC,CACzD;;;;;;;;IA8BC,IAAc,QAAQ;QACpB,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;KAChC;;;;;;;;;;;;IAaD,IAAc,iBAAiB;QAC7B,MAAM,OAAO,GAAkB;YAC7B,wBAAwB,EAAE,IAAI,CAAC,QAAQ;YACvC,kBAAkB,EAAE,IAAI,CAAC,QAAQ;YACjC,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ;SACjC,CAAC;QACF,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC7C;QACD,OAAO,OAAO,CAAC;KAChB;;;;;;;;;IAUD,IAAc,UAAU;QACtB,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QACzF,OAAO,YAAY,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS;cACxC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC;cACzF,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;KAC9C;;;;;;;;;;;IAYS,OAAO,CAAC,KAAa,EAAE,KAAa,EAAE,GAAW;QACzD,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC;YAChC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;YAClC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC;SAC1B,CAAC;KACH;CACF,CAAA;AAlFC;IADC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;uCACD;AAQrB;IADC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;4CACI;AAM1B;IADC,IAAI,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;6CACK;AAvBR,SAAS;IAH7B,SAAS,CAAC;QACT,UAAU,EAAE,EAAE,SAAS,EAAE;KAC1B,CAAC;GACmB,SAAS,CA2F7B;aA3FoB,SAAS;;;;"}
|