@salla.sa/twilight-components 2.11.110 → 2.11.111
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 +48 -42
- package/dist/cjs/{app-globals-c392da62.js → app-globals-38ac4fe8.js} +2 -2
- package/dist/cjs/{app-globals-c392da62.js.map → app-globals-38ac4fe8.js.map} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-add-product-button_40.cjs.entry.js +73 -23
- package/dist/cjs/salla-add-product-button_40.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +5 -27
- package/dist/cjs/salla-filters-widget.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +8 -4
- package/dist/cjs/salla-filters.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +109 -37
- package/dist/cjs/salla-price-range.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-products-list.cjs.entry.js +85 -59
- package/dist/cjs/salla-products-list.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-products-slider.cjs.entry.js +12 -4
- package/dist/cjs/salla-products-slider.cjs.entry.js.map +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/collection/components/salla-filters/salla-filters.js +8 -4
- package/dist/collection/components/salla-filters/salla-filters.js.map +1 -1
- package/dist/collection/components/salla-filters-widget/salla-filters-widget.js +5 -27
- package/dist/collection/components/salla-filters-widget/salla-filters-widget.js.map +1 -1
- package/dist/collection/components/salla-login-modal/intefaces.js.map +1 -1
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +1 -1
- package/dist/collection/components/salla-login-modal/salla-login-modal.js.map +1 -1
- package/dist/collection/components/salla-maintenance-alert/salla-maintenance-alert.js +14 -1
- package/dist/collection/components/salla-maintenance-alert/salla-maintenance-alert.js.map +1 -1
- package/dist/collection/components/salla-price-range/salla-price-range.js +152 -148
- package/dist/collection/components/salla-price-range/salla-price-range.js.map +1 -1
- package/dist/collection/components/salla-products-list/salla-products-list.js +85 -59
- package/dist/collection/components/salla-products-list/salla-products-list.js.map +1 -1
- package/dist/collection/components/salla-products-slider/salla-products-slider.js +29 -5
- package/dist/collection/components/salla-products-slider/salla-products-slider.js.map +1 -1
- package/dist/collection/components/salla-verify/salla-verify.css +12 -0
- package/dist/collection/components/salla-verify/salla-verify.js +58 -20
- package/dist/collection/components/salla-verify/salla-verify.js.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/salla-filters-widget2.js +5 -27
- package/dist/components/salla-filters-widget2.js.map +1 -1
- package/dist/components/salla-filters.js +8 -4
- package/dist/components/salla-filters.js.map +1 -1
- package/dist/components/salla-login-modal.js +1 -1
- package/dist/components/salla-login-modal.js.map +1 -1
- package/dist/components/salla-maintenance-alert.js +14 -1
- package/dist/components/salla-maintenance-alert.js.map +1 -1
- package/dist/components/salla-price-range2.js +113 -43
- package/dist/components/salla-price-range2.js.map +1 -1
- package/dist/components/salla-products-list.js +85 -59
- package/dist/components/salla-products-list.js.map +1 -1
- package/dist/components/salla-products-slider.js +13 -5
- package/dist/components/salla-products-slider.js.map +1 -1
- package/dist/components/salla-verify2.js +59 -21
- package/dist/components/salla-verify2.js.map +1 -1
- package/dist/esm/{app-globals-663240cc.js → app-globals-3a81b4f2.js} +2 -2
- package/dist/esm/{app-globals-663240cc.js.map → app-globals-3a81b4f2.js.map} +1 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/salla-add-product-button_40.entry.js +73 -23
- package/dist/esm/salla-add-product-button_40.entry.js.map +1 -1
- package/dist/esm/salla-filters-widget.entry.js +5 -27
- package/dist/esm/salla-filters-widget.entry.js.map +1 -1
- package/dist/esm/salla-filters.entry.js +8 -4
- package/dist/esm/salla-filters.entry.js.map +1 -1
- package/dist/esm/salla-price-range.entry.js +109 -37
- package/dist/esm/salla-price-range.entry.js.map +1 -1
- package/dist/esm/salla-products-list.entry.js +85 -59
- package/dist/esm/salla-products-list.entry.js.map +1 -1
- package/dist/esm/salla-products-slider.entry.js +12 -4
- package/dist/esm/salla-products-slider.entry.js.map +1 -1
- package/dist/esm/twilight.js +2 -2
- package/dist/esm-es5/{app-globals-663240cc.js → app-globals-3a81b4f2.js} +2 -2
- package/dist/{twilight/p-dcfa0f39.system.js.map → esm-es5/app-globals-3a81b4f2.js.map} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/loader.js.map +1 -1
- package/dist/esm-es5/salla-add-product-button_40.entry.js +4 -4
- package/dist/esm-es5/salla-add-product-button_40.entry.js.map +1 -1
- package/dist/esm-es5/salla-filters-widget.entry.js +1 -1
- package/dist/esm-es5/salla-filters-widget.entry.js.map +1 -1
- package/dist/esm-es5/salla-filters.entry.js +1 -1
- package/dist/esm-es5/salla-filters.entry.js.map +1 -1
- package/dist/esm-es5/salla-price-range.entry.js +2 -2
- package/dist/esm-es5/salla-price-range.entry.js.map +1 -1
- package/dist/esm-es5/salla-products-list.entry.js +2 -2
- package/dist/esm-es5/salla-products-list.entry.js.map +1 -1
- package/dist/esm-es5/salla-products-slider.entry.js +1 -1
- package/dist/esm-es5/salla-products-slider.entry.js.map +1 -1
- package/dist/esm-es5/twilight.js +1 -1
- package/dist/esm-es5/twilight.js.map +1 -1
- package/dist/twilight/{p-6948b825.js → p-1edec127.js} +2 -2
- package/dist/twilight/{p-6948b825.js.map → p-1edec127.js.map} +1 -1
- package/dist/twilight/{p-7c6638f5.system.entry.js → p-2739ddc5.system.entry.js} +2 -2
- package/dist/twilight/p-2739ddc5.system.entry.js.map +1 -0
- package/dist/twilight/p-3212e42c.entry.js +5 -0
- package/dist/twilight/p-3212e42c.entry.js.map +1 -0
- package/dist/twilight/{p-6404a9a5.system.js → p-37389934.system.js} +2 -2
- package/dist/twilight/{p-6404a9a5.system.js.map → p-37389934.system.js.map} +1 -1
- package/dist/twilight/{p-dcfa0f39.system.js → p-38496eab.system.js} +2 -2
- package/dist/{esm-es5/app-globals-663240cc.js.map → twilight/p-38496eab.system.js.map} +1 -1
- package/dist/twilight/p-3f03d17c.system.entry.js +5 -0
- package/dist/twilight/p-3f03d17c.system.entry.js.map +1 -0
- package/dist/twilight/p-46b7f931.system.entry.js +5 -0
- package/dist/twilight/p-46b7f931.system.entry.js.map +1 -0
- package/dist/twilight/p-54783694.system.entry.js +5 -0
- package/dist/twilight/p-54783694.system.entry.js.map +1 -0
- package/dist/twilight/{p-9713044b.entry.js → p-5b15c1a6.entry.js} +2 -2
- package/dist/twilight/p-5b15c1a6.entry.js.map +1 -0
- package/dist/twilight/p-cd5cb2f7.entry.js +5 -0
- package/dist/twilight/p-cd5cb2f7.entry.js.map +1 -0
- package/dist/twilight/p-d7a62fb3.system.entry.js +5 -0
- package/dist/twilight/p-d7a62fb3.system.entry.js.map +1 -0
- package/dist/twilight/p-def222e1.entry.js +5 -0
- package/dist/twilight/p-def222e1.entry.js.map +1 -0
- package/dist/twilight/p-e393f123.entry.js +5 -0
- package/dist/twilight/p-e393f123.entry.js.map +1 -0
- package/dist/twilight/p-e3dc0687.entry.js +5 -0
- package/dist/twilight/p-e3dc0687.entry.js.map +1 -0
- package/dist/twilight/{p-1e4abb42.system.entry.js → p-fcc169b5.system.entry.js} +2 -2
- package/dist/twilight/p-fcc169b5.system.entry.js.map +1 -0
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/twilight/twilight.esm.js.map +1 -1
- package/dist/twilight/twilight.js +1 -1
- package/dist/types/components/salla-filters-widget/salla-filters-widget.d.ts +0 -7
- package/dist/types/components/salla-login-modal/intefaces.d.ts +1 -0
- package/dist/types/components/salla-maintenance-alert/salla-maintenance-alert.d.ts +3 -0
- package/dist/types/components/salla-price-range/salla-price-range.d.ts +16 -10
- package/dist/types/components/salla-products-list/salla-products-list.d.ts +2 -2
- package/dist/types/components/salla-products-slider/salla-products-slider.d.ts +5 -1
- package/dist/types/components/salla-verify/salla-verify.d.ts +6 -1
- package/dist/types/components.d.ts +14 -8
- package/package.json +4 -4
- package/dist/twilight/p-1e4abb42.system.entry.js.map +0 -1
- package/dist/twilight/p-3b1a0059.entry.js +0 -5
- package/dist/twilight/p-3b1a0059.entry.js.map +0 -1
- package/dist/twilight/p-41b3e09d.entry.js +0 -5
- package/dist/twilight/p-41b3e09d.entry.js.map +0 -1
- package/dist/twilight/p-4a743b5e.system.entry.js +0 -5
- package/dist/twilight/p-4a743b5e.system.entry.js.map +0 -1
- package/dist/twilight/p-62c1b309.entry.js +0 -5
- package/dist/twilight/p-62c1b309.entry.js.map +0 -1
- package/dist/twilight/p-6349125a.entry.js +0 -5
- package/dist/twilight/p-6349125a.entry.js.map +0 -1
- package/dist/twilight/p-7c6638f5.system.entry.js.map +0 -1
- package/dist/twilight/p-8ee37cc6.entry.js +0 -5
- package/dist/twilight/p-8ee37cc6.entry.js.map +0 -1
- package/dist/twilight/p-9713044b.entry.js.map +0 -1
- package/dist/twilight/p-9e27da8e.system.entry.js +0 -5
- package/dist/twilight/p-9e27da8e.system.entry.js.map +0 -1
- package/dist/twilight/p-b1f8b436.system.entry.js +0 -5
- package/dist/twilight/p-b1f8b436.system.entry.js.map +0 -1
- package/dist/twilight/p-c9cdaea6.system.entry.js +0 -5
- package/dist/twilight/p-c9cdaea6.system.entry.js.map +0 -1
|
@@ -30,12 +30,8 @@ const SallaFiltersWidget = class {
|
|
|
30
30
|
this.widgetContent.style.height = `${this.widgetContent.scrollHeight}px`;
|
|
31
31
|
}
|
|
32
32
|
async reset() {
|
|
33
|
-
var _a, _b;
|
|
34
33
|
if (this.option.type === FilterOptionTypes.RANGE) {
|
|
35
|
-
this.priceRange.
|
|
36
|
-
this.priceRange.maxPrice = (_b = this.option.values) === null || _b === void 0 ? void 0 : _b.max;
|
|
37
|
-
await this.priceRange.maxTrigger();
|
|
38
|
-
await this.priceRange.minTrigger();
|
|
34
|
+
this.priceRange.reset();
|
|
39
35
|
}
|
|
40
36
|
Array.from(this.host.querySelectorAll('input')).forEach(input => input.checked = false);
|
|
41
37
|
}
|
|
@@ -51,27 +47,6 @@ const SallaFiltersWidget = class {
|
|
|
51
47
|
this.isOpen = !this.isOpen;
|
|
52
48
|
Helper.toggleElementClassIf(this.widgetContent, 's-filters-widget-opened', 's-filters-widget-closed', () => this.isOpen);
|
|
53
49
|
}
|
|
54
|
-
/**
|
|
55
|
-
* @param {currentTarget: HTMLSallaPriceRangeElement} event
|
|
56
|
-
* @param option
|
|
57
|
-
* @private
|
|
58
|
-
*/
|
|
59
|
-
handlePriceSelection(event, option) {
|
|
60
|
-
this.changed.emit({
|
|
61
|
-
event: event,
|
|
62
|
-
option: option,
|
|
63
|
-
value: {
|
|
64
|
-
max: event.currentTarget.maxPrice,
|
|
65
|
-
min: event.currentTarget.minPrice,
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
renderSliderOption(option) {
|
|
70
|
-
if (option.type !== FilterOptionTypes.RANGE) {
|
|
71
|
-
return '';
|
|
72
|
-
}
|
|
73
|
-
return h("salla-price-range", { onMinPriceSelected: (event) => this.handlePriceSelection(event, option), onMaxPriceSelected: (event) => this.handlePriceSelection(event, option), ref: el => this.priceRange = el, "min-price": option.values.min, "max-price": option.values.max });
|
|
74
|
-
}
|
|
75
50
|
renderFilterOption(option) {
|
|
76
51
|
if (![FilterOptionTypes.VALUES, FilterOptionTypes.MINIMUM, FilterOptionTypes.VARIANTS].includes(option.type)) {
|
|
77
52
|
return '';
|
|
@@ -94,6 +69,7 @@ const SallaFiltersWidget = class {
|
|
|
94
69
|
}
|
|
95
70
|
getOptionLabel(option, filterOption) {
|
|
96
71
|
if (option.key == 'rating') {
|
|
72
|
+
//in amazon has stars & up, should we add it, to avoid those people who will come to say I selected 4 why I see 5 sars products
|
|
97
73
|
return h("salla-rating-stars", { size: "small", value: filterOption });
|
|
98
74
|
}
|
|
99
75
|
let label = filterOption.value || 'null';
|
|
@@ -101,7 +77,9 @@ const SallaFiltersWidget = class {
|
|
|
101
77
|
return h("span", { class: "s-filters-option-name" }, label);
|
|
102
78
|
}
|
|
103
79
|
render() {
|
|
104
|
-
return (h(Host, { class: "s-filters-widget-container" }, h("h3", { class: "s-filters-widget-title", onClick: () => this.toggleWidget() }, h("span", null, this.widgetTitle), h("span", { class: `s-filters-widget-plusminus ${this.isOpen ? 's-filters-widget-plusminus-active' : ''}` })), h("div", { class: "s-filters-widget-content", ref: (el) => this.widgetContent = el }, h("div", { class: "s-filters-widget-values", ref: (el) => this.widgetValues = el }, h("slot", null), this.
|
|
80
|
+
return (h(Host, { class: "s-filters-widget-container" }, h("h3", { class: "s-filters-widget-title", onClick: () => this.toggleWidget() }, h("span", null, this.widgetTitle), h("span", { class: `s-filters-widget-plusminus ${this.isOpen ? 's-filters-widget-plusminus-active' : ''}` })), h("div", { class: "s-filters-widget-content", ref: (el) => this.widgetContent = el }, h("div", { class: "s-filters-widget-values", ref: (el) => this.widgetValues = el }, h("slot", null), this.option.type !== FilterOptionTypes.RANGE
|
|
81
|
+
? this.renderFilterOption(this.option)
|
|
82
|
+
: h("salla-price-range", { onChanged: (event) => this.changed.emit(event.detail), ref: price => this.priceRange = price, filtersData: this.filtersData, option: this.option })), this.withLoadMore &&
|
|
105
83
|
h("a", { class: "s-filters-widget-more", onClick: () => this.showMore() }, !this.isShowMore ? 'عرض المزيد' : 'عرض أقل'))));
|
|
106
84
|
}
|
|
107
85
|
get host() { return getElement(this); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"salla-filters-widget.entry.js","mappings":";;;;;;;AAAA,MAAM,qBAAqB,GAAG,sBAAsB;;MCQvC,kBAAkB;;;;IAWrB,eAAU,GAAW,GAAG,CAAC;;;;;kBACN,IAAI;sBACA,KAAK;;EAIpC,iBAAiB;;IAEf,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACvF,IAAI,CAAC,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filters-widget/salla-filters-widget.scss?tag=salla-filters-widget","./src/components/salla-filters-widget/salla-filters-widget.tsx"],"sourcesContent":[":host {\n display: block;\n}\n","import {Component, Host, h, Method, State, Prop, Event, Element} from '@stencil/core';\nimport Helper from '../../Helpers/Helper';\nimport {Filter, FilterOptionInputType, FilterOptionTypes} from \"../salla-filters/interfaces\";\n\n@Component({\n tag: 'salla-filters-widget',\n styleUrl: 'salla-filters-widget.scss',\n})\nexport class SallaFiltersWidget {\n @Element() host: HTMLElement;\n @Prop({mutable: true}) widgetTitle: string;\n @Prop({mutable: true}) withLoadMore: boolean;\n @Prop({reflect: true}) filtersData: object;\n @Prop({reflect: true}) option: Filter;\n priceRange: HTMLSallaPriceRangeElement\n\n\n private widgetValues: HTMLElement;\n private widgetContent: HTMLDivElement;\n private initHeight: number = 195;\n @State() isOpen: boolean = true;\n @State() isShowMore: boolean = false;\n\n @Event() changed: any;\n\n connectedCallback() {\n //lets be smart and don't show 5 and more link for 8 options\n this.withLoadMore = Array.isArray(this.option.values) && this.option.values.length > 8;\n this.widgetTitle = this.option.label;\n }\n\n componentDidLoad() {\n this.widgetValues.scrollHeight < this.initHeight && (this.withLoadMore = false);\n (this.withLoadMore && this.widgetValues) && (this.widgetValues.style.maxHeight = `${this.initHeight}px`);\n this.widgetContent.style.height = `${this.widgetContent.scrollHeight}px`;\n }\n\n @Method()\n async reset() {\n if (this.option.type === FilterOptionTypes.RANGE) {\n this.priceRange.minPrice = (this.option.values as any)?.min;\n this.priceRange.maxPrice = (this.option.values as any)?.max;\n await this.priceRange.maxTrigger();\n await this.priceRange.minTrigger();\n }\n Array.from(this.host.querySelectorAll('input')).forEach(input => input.checked = false);\n }\n\n @Method()\n async showMore() {\n this.isShowMore = !this.isShowMore\n this.widgetContent.style.height = 'auto';\n this.widgetValues.style.maxHeight = this.isShowMore ? `${this.widgetValues.scrollHeight}px` : `${this.initHeight}px`;\n setTimeout(() => {\n this.widgetContent.style.height = `${this.widgetContent.scrollHeight}px`;\n }, 400); // get height after time of collapse animtion (duration-300)\n }\n\n @Method()\n async toggleWidget() {\n this.isOpen = !this.isOpen;\n Helper.toggleElementClassIf(this.widgetContent, 's-filters-widget-opened', 's-filters-widget-closed', () => this.isOpen);\n }\n\n /**\n * @param {currentTarget: HTMLSallaPriceRangeElement} event\n * @param option\n * @private\n */\n private handlePriceSelection(event, option: Filter) {\n this.changed.emit({\n event: event,\n option: option,\n value: {\n max: event.currentTarget.maxPrice,\n min: event.currentTarget.minPrice,\n }\n })\n }\n\n renderSliderOption(option) {\n if (option.type !== FilterOptionTypes.RANGE) {\n return '';\n }\n return <salla-price-range\n onMinPriceSelected={(event) => this.handlePriceSelection(event, option)}\n onMaxPriceSelected={(event) => this.handlePriceSelection(event, option)}\n ref={el => this.priceRange = el}\n min-price={option.values.min}\n max-price={option.values.max}/>;\n }\n\n renderFilterOption(option: Filter) {\n if (![FilterOptionTypes.VALUES, FilterOptionTypes.MINIMUM, FilterOptionTypes.VARIANTS].includes(option.type)) {\n return '';\n }\n //@ts-ignore\n return option.values.map((filterOption, index) => {\n let value = typeof filterOption == 'number' ? filterOption : (filterOption.key || filterOption.value);\n\n return <label class=\"s-filters-label\" htmlFor={`${option.key}-option-${index}`}>\n <input\n id={`${option.key}-option-${index}`}\n name={option.key}\n type={option.inputType}\n //TODO:: debug more why sometimes it's not rendered as selected🤨\n checked={this.isSelectedOption(option, value)}\n class={`s-filters-${option.inputType}`}\n onChange={e => this.changed.emit({event: e, option: option, value: value})}\n />\n {this.getOptionLabel(option, filterOption)}\n </label>\n }\n )\n }\n\n private isSelectedOption(option: Filter, value) {\n if (!this.filtersData || !this.filtersData[option.key]) {\n return false\n }\n\n return option.inputType === FilterOptionInputType.CHECKBOX\n ? this.filtersData[option.key].includes(value)\n : this.filtersData[option.key] == value;\n }\n\n private getOptionLabel(option: Filter, filterOption) {\n if (option.key == 'rating') {\n return <salla-rating-stars size=\"small\" value={filterOption}/>;\n }\n let label = filterOption.value || 'null';\n //label+=filterOption.count ? ` (${salla.helpers.number(filterOption.count)})` : '';\n return <span class=\"s-filters-option-name\">{label}</span>;\n }\n\n render() {\n return (\n <Host class=\"s-filters-widget-container\">\n <h3 class=\"s-filters-widget-title\" onClick={() => this.toggleWidget()}>\n <span>{this.widgetTitle}</span>\n <span class={`s-filters-widget-plusminus ${this.isOpen ? 's-filters-widget-plusminus-active' : ''}`}/>\n </h3>\n <div class=\"s-filters-widget-content\" ref={(el) => this.widgetContent = el}>\n <div class=\"s-filters-widget-values\" ref={(el) => this.widgetValues = el}>\n <slot/>\n {this.renderFilterOption(this.option)}\n {this.renderSliderOption(this.option)}\n </div>\n {this.withLoadMore &&\n <a class=\"s-filters-widget-more\"\n onClick={() => this.showMore()}>{!this.isShowMore ? 'عرض المزيد' : 'عرض أقل'}</a>\n }\n </div>\n </Host>\n );\n }\n\n}\n"],"version":3}
|
|
1
|
+
{"file":"salla-filters-widget.entry.js","mappings":";;;;;;;AAAA,MAAM,qBAAqB,GAAG,sBAAsB;;MCQvC,kBAAkB;;;;IAWrB,eAAU,GAAW,GAAG,CAAC;;;;;kBACN,IAAI;sBACA,KAAK;;EAIpC,iBAAiB;;IAEf,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACvF,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;GACtC;EAED,gBAAgB;IACd,IAAI,CAAC,YAAY,CAAC,YAAY,GAAG,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC;IAChF,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,GAAG,GAAG,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC;IACzG,IAAI,CAAC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EAAE,MAAM,IAAI,CAAC,QAAQ,EAAE,IAAG,CAAC,IAAI,CAAC,UAAU,GAAG,YAAY,GAAG,SAAS,CAAK,CAEhF,CACD,EACP;GACH;;;;;;;","names":[],"sources":["./src/components/salla-filters-widget/salla-filters-widget.scss?tag=salla-filters-widget","./src/components/salla-filters-widget/salla-filters-widget.tsx"],"sourcesContent":[":host {\n display: block;\n}\n","import {Component, Host, h, Method, State, Prop, Event, Element} from '@stencil/core';\nimport Helper from '../../Helpers/Helper';\nimport {Filter, FilterOptionInputType, FilterOptionTypes} from \"../salla-filters/interfaces\";\n\n@Component({\n tag: 'salla-filters-widget',\n styleUrl: 'salla-filters-widget.scss',\n})\nexport class SallaFiltersWidget {\n @Element() host: HTMLElement;\n @Prop({mutable: true}) widgetTitle: string;\n @Prop({mutable: true}) withLoadMore: boolean;\n @Prop({reflect: true}) filtersData: object;\n @Prop({reflect: true}) option: Filter;\n priceRange: HTMLSallaPriceRangeElement\n\n\n private widgetValues: HTMLElement;\n private widgetContent: HTMLDivElement;\n private initHeight: number = 195;\n @State() isOpen: boolean = true;\n @State() isShowMore: boolean = false;\n\n @Event() changed: any;\n\n connectedCallback() {\n //lets be smart and don't show 5 and more link for 8 options\n this.withLoadMore = Array.isArray(this.option.values) && this.option.values.length > 8;\n this.widgetTitle = this.option.label;\n }\n\n componentDidLoad() {\n this.widgetValues.scrollHeight < this.initHeight && (this.withLoadMore = false);\n (this.withLoadMore && this.widgetValues) && (this.widgetValues.style.maxHeight = `${this.initHeight}px`);\n this.widgetContent.style.height = `${this.widgetContent.scrollHeight}px`;\n }\n\n @Method()\n async reset() {\n if (this.option.type === FilterOptionTypes.RANGE) {\n this.priceRange.reset()\n }\n Array.from(this.host.querySelectorAll('input')).forEach(input => input.checked = false);\n }\n\n\n @Method()\n async showMore() {\n this.isShowMore = !this.isShowMore\n this.widgetContent.style.height = 'auto';\n this.widgetValues.style.maxHeight = this.isShowMore ? `${this.widgetValues.scrollHeight}px` : `${this.initHeight}px`;\n setTimeout(() => {\n this.widgetContent.style.height = `${this.widgetContent.scrollHeight}px`;\n }, 400); // get height after time of collapse animtion (duration-300)\n }\n\n @Method()\n async toggleWidget() {\n this.isOpen = !this.isOpen;\n Helper.toggleElementClassIf(this.widgetContent, 's-filters-widget-opened', 's-filters-widget-closed', () => this.isOpen);\n }\n\n renderFilterOption(option: Filter) {\n if (![FilterOptionTypes.VALUES, FilterOptionTypes.MINIMUM, FilterOptionTypes.VARIANTS].includes(option.type)) {\n return '';\n }\n //@ts-ignore\n return option.values.map((filterOption, index) => {\n let value = typeof filterOption == 'number' ? filterOption : (filterOption.key || filterOption.value);\n\n return <label class=\"s-filters-label\" htmlFor={`${option.key}-option-${index}`}>\n <input\n id={`${option.key}-option-${index}`}\n name={option.key}\n type={option.inputType}\n //TODO:: debug more why sometimes it's not rendered as selected🤨\n checked={this.isSelectedOption(option, value)}\n class={`s-filters-${option.inputType}`}\n onChange={e => this.changed.emit({event: e, option: option, value: value})}\n />\n {this.getOptionLabel(option, filterOption)}\n </label>\n }\n )\n }\n\n private isSelectedOption(option: Filter, value) {\n if (!this.filtersData || !this.filtersData[option.key]) {\n return false\n }\n\n return option.inputType === FilterOptionInputType.CHECKBOX\n ? this.filtersData[option.key].includes(value)\n : this.filtersData[option.key] == value;\n }\n\n private getOptionLabel(option: Filter, filterOption) {\n if (option.key == 'rating') {\n //in amazon has stars & up, should we add it, to avoid those people who will come to say I selected 4 why I see 5 sars products\n return <salla-rating-stars size=\"small\" value={filterOption}/>;\n }\n let label = filterOption.value || 'null';\n //label+=filterOption.count ? ` (${salla.helpers.number(filterOption.count)})` : '';\n return <span class=\"s-filters-option-name\">{label}</span>;\n }\n\n render() {\n return (\n <Host class=\"s-filters-widget-container\">\n <h3 class=\"s-filters-widget-title\" onClick={() => this.toggleWidget()}>\n <span>{this.widgetTitle}</span>\n <span class={`s-filters-widget-plusminus ${this.isOpen ? 's-filters-widget-plusminus-active' : ''}`}/>\n </h3>\n <div class=\"s-filters-widget-content\" ref={(el) => this.widgetContent = el}>\n <div class=\"s-filters-widget-values\" ref={(el) => this.widgetValues = el}>\n <slot/>\n {\n this.option.type !== FilterOptionTypes.RANGE\n ? this.renderFilterOption(this.option)\n : <salla-price-range onChanged={(event) => this.changed.emit(event.detail)}\n ref={price => this.priceRange = price}\n filtersData={this.filtersData}\n option={this.option}/>\n }\n </div>\n {this.withLoadMore &&\n <a class=\"s-filters-widget-more\"\n onClick={() => this.showMore()}>{!this.isShowMore ? 'عرض المزيد' : 'عرض أقل'}</a>\n }\n </div>\n </Host>\n );\n }\n\n}\n"],"version":3}
|
|
@@ -38,7 +38,7 @@ const SallaFilters = class {
|
|
|
38
38
|
//@ts-ignore
|
|
39
39
|
let { max, min } = filter.values;
|
|
40
40
|
//@ts-ignore
|
|
41
|
-
filter.values = [
|
|
41
|
+
filter.values = [5, 4, 3, 2, 1].filter(stars => stars >= min || stars <= max);
|
|
42
42
|
}
|
|
43
43
|
//when getting new filters, maybe less than we had, so let's get from the old one, only what is existed now.
|
|
44
44
|
if (this.filtersData[filter.key]) {
|
|
@@ -66,9 +66,13 @@ const SallaFilters = class {
|
|
|
66
66
|
if (!this.isReady) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
//todo:: why we need this🤔
|
|
70
|
+
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
window.history.pushState({}, '', salla.url.addParamToUrl('filters', encodeURIComponent(JSON.stringify(this.filtersData))));
|
|
73
|
+
salla.event.emit('salla-filters::changed', this.filtersData);
|
|
74
|
+
this.changed.emit(this.filtersData);
|
|
75
|
+
}, 300);
|
|
72
76
|
}
|
|
73
77
|
async resetFilters() {
|
|
74
78
|
this.filtersData = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"salla-filters.entry.js","mappings":";;;;;;AAAA,MAAM,eAAe,GAAG,+GAA+G;;MCU1H,YAA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kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAI,CAAC,EAExG,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,KAAI,WAAK,KAAK,EAAC,kBAAkB,IACpD,oBAAc,KAAK,EAAC,SAAS,EAAC,OAAO,EAAE,MAAM,IAAI,CAAC,YAAY,EAAE,IAAG,IAAI,CAAC,KAAK,CAAgB,EAC7F,oBAAc,KAAK,EAAC,MAAM,EAAC,IAAI,EAAC,SAAS,EAAC,OAAO,EAAE,MAAM,IAAI,CAAC,YAAY,EAAE,IAAG,IAAI,CAAC,KAAK,CAAgB,CACrG,CACD,CAAC;GACT;EAED,gBAAgB;IACd,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;GACrB;;;;;;;","names":[],"sources":["./src/components/salla-filters/salla-filters.scss?tag=salla-filters","./src/components/salla-filters/salla-filters.tsx"],"sourcesContent":[":host {\n display: block;\n}\n\n.s-rating-stars-small {\n line-height: 12px;\n}\n.s-filters-radio{\n background-image: none !important;\n}","import { Component, Element, h, Event, EventEmitter, Host, Method, Prop, State } from '@stencil/core';\nimport { Filter, FilterOptionInputType, FilterOptionTypes } from \"./interfaces\";\n\n//todo::\n\n\n@Component({\n tag: 'salla-filters',\n styleUrl: 'salla-filters.scss',\n})\nexport class SallaFilters {\n\n constructor() {\n salla.event.on('filters::hidden', () => this.host.style.display = 'none');\n\n salla.lang.onLoaded(() => {\n this.apply = salla.lang.get('pages.checkout.apply');\n this.reset = salla.lang.get('pages.categories.filters_reset');\n });\n\n salla.event.on('filters::fetched', ({ filters }) => {\n this.host.style.display = '';\n let freshFilterData = {};\n this.filters = filters\n .map((filter: Filter) => {\n filter.label = {\n category_id: salla.lang.get('common.titles.categories'),\n brand_id: salla.lang.get('common.titles.brands'),\n rating: salla.lang.get('pages.categories.filter_rating'),\n price_range: salla.lang.get('pages.categories.filter_price'),\n }[filter.key] || filter.label;\n filter.inputType = FilterOptionInputType.CHECKBOX;\n if (filter.key == 'rating') {\n filter.inputType = FilterOptionInputType.RADIO;\n //@ts-ignore\n let { max, min } = filter.values;\n //@ts-ignore\n filter.values = [5, 4, 3, 2, 1].filter(stars => stars >= min || stars <= max)\n }\n\n //when getting new filters, maybe less than we had, so let's get from the old one, only what is existed now.\n if (this.filtersData[filter.key]) {\n freshFilterData[filter.key] = this.filtersData[filter.key];\n }\n\n return filter;\n });\n this.filtersData = freshFilterData;\n });\n }\n\n connectedCallback() {\n try {\n let filters = (new URLSearchParams(window.location.search)).get('filters')\n this.filtersData = filters ? JSON.parse(decodeURIComponent(filters)) : {};\n } catch (e) {\n salla.logger.warn('failed to get filters from url', e.message);\n }\n }\n\n @Element() host: HTMLElement;\n @Prop({ reflect: true, mutable: true }) filters?: Filter[];\n private isReady = false;//to avoid triggering the changed event\n @State() isSidebarOpen: boolean;\n @State() filtersData: object = {}\n @State() apply: string;\n @State() reset: string;\n @Event() changed: EventEmitter;\n\n //TODO:: move all @methods into one section\n @Method()\n async getFilters() {\n return this.filtersData;\n }\n\n @Method()\n async applyFilters() {\n if (!this.isReady) {\n return;\n }\n //todo:: why we need this🤔\n window.scrollTo({top: 0,behavior: 'smooth'});\n setTimeout(() => {\n window.history.pushState({}, '', salla.url.addParamToUrl('filters', encodeURIComponent(JSON.stringify(this.filtersData))));\n salla.event.emit('salla-filters::changed', this.filtersData);\n this.changed.emit(this.filtersData);\n }, 300);\n }\n\n @Method()\n async resetFilters() {\n this.filtersData = {};\n this.host.childNodes.forEach((widget: HTMLSallaFiltersWidgetElement) => widget.reset && widget.reset())\n salla.event.emit('salla-filters::reset');\n return this.applyFilters();\n }\n\n /**\n * @param {{target:HTMLInputElement}} event\n * @param option\n * @param value\n * @private\n */\n private handleOptionChange(event, option: Filter, value) {\n if (option.type === FilterOptionTypes.RANGE) {\n this.filtersData[option.key] = value;\n return;\n }\n let isChecked = event.target.checked;\n if (event.target.type == FilterOptionInputType.RADIO) {\n isChecked && (this.filtersData[option.key] = value);\n isChecked || (delete this.filtersData[option.key]);\n return;\n }\n\n //it's checkbox\n this.filtersData[option.key] = this.filtersData[option.key] || [];\n if (isChecked) {\n this.filtersData[option.key].push(value);\n return;\n }\n this.filtersData[option.key] = this.filtersData[option.key].filter(val => val != value);\n }\n\n render() {\n return <Host>\n {this.filters?.map(option => <salla-filters-widget\n option={option}\n filtersData={this.filtersData}\n onChanged={({ detail: { event, option, value } }) => this.handleOptionChange(event, option, value)} />)}\n\n {this.filters?.length && <div class=\"s-filters-footer\">\n <salla-button color='primary' onClick={() => this.applyFilters()}>{this.apply}</salla-button>\n <salla-button color='gray' fill='outline' onClick={() => this.resetFilters()}>{this.reset}</salla-button>\n </div>}\n </Host>;\n }\n\n componentDidLoad() {\n this.isReady = true;\n }\n}\n\n"],"version":3}
|
|
@@ -8,68 +8,140 @@ const sallaPriceRangeCss = ":host{display:block}.rtl .rtl-range-slider,[dir=rtl]
|
|
|
8
8
|
const SallaPriceRange = class {
|
|
9
9
|
constructor(hostRef) {
|
|
10
10
|
registerInstance(this, hostRef);
|
|
11
|
-
this.
|
|
12
|
-
this.maxPriceSelected = createEvent(this, "maxPriceSelected", 7);
|
|
11
|
+
this.changed = createEvent(this, "changed", 7);
|
|
13
12
|
this.minPrice = 1000;
|
|
14
13
|
this.maxPrice = 5000;
|
|
14
|
+
this.option = undefined;
|
|
15
|
+
this.filtersData = undefined;
|
|
15
16
|
this.min = 0;
|
|
16
17
|
this.max = 10000;
|
|
17
18
|
this.minthumb = 0;
|
|
18
19
|
this.maxthumb = 0;
|
|
20
|
+
this.priceOptions = undefined;
|
|
21
|
+
this.generatePriceOptions();
|
|
19
22
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
async reset() {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
//@ts-ignore
|
|
26
|
+
this.minInput.value = `${((_b = (_a = this.option) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b.min) || 0}`;
|
|
27
|
+
this.maxInput.value = `${this.max}`;
|
|
23
28
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
generatePriceOptions() {
|
|
30
|
+
const MAX_PRICE = this.max;
|
|
31
|
+
let option1 = Math.floor(MAX_PRICE / 100);
|
|
32
|
+
if (option1 < 1) {
|
|
33
|
+
option1 = Math.floor(MAX_PRICE / 10);
|
|
34
|
+
}
|
|
35
|
+
let option2 = Math.floor(MAX_PRICE / 2);
|
|
36
|
+
let option3 = Math.floor((MAX_PRICE / 3) * 2);
|
|
37
|
+
this.priceOptions = [option1, option2, option3];
|
|
38
|
+
// to be removed
|
|
39
|
+
console.log(`Price options for max price ${MAX_PRICE}: ${this.priceOptions.join(', ')}`);
|
|
40
|
+
}
|
|
41
|
+
getPriceLabel(price) {
|
|
42
|
+
if (price == Math.floor(this.max / 100)) {
|
|
43
|
+
return `اقل من ${salla.money(price)}`;
|
|
44
|
+
}
|
|
45
|
+
else if (price == Math.floor(this.max / 2)) {
|
|
46
|
+
return `${salla.money(this.priceOptions[0])} الى ${salla.money(this.priceOptions[2])}`;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return `أكثر من ${salla.money(price)}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
handleMinMaxPrice(event, option) {
|
|
53
|
+
const [firstOption, secondOption, thirdOption] = this.priceOptions;
|
|
54
|
+
switch (option) {
|
|
55
|
+
case firstOption:
|
|
56
|
+
this.minPrice = 0;
|
|
57
|
+
this.maxPrice = firstOption;
|
|
58
|
+
break;
|
|
59
|
+
case secondOption:
|
|
60
|
+
this.minPrice = firstOption;
|
|
61
|
+
this.maxPrice = thirdOption;
|
|
62
|
+
break;
|
|
63
|
+
case thirdOption:
|
|
64
|
+
this.minPrice = thirdOption;
|
|
65
|
+
this.maxPrice = this.max;
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
throw new Error(`Invalid price option: ${option}`);
|
|
69
|
+
}
|
|
70
|
+
// Update the input values
|
|
71
|
+
this.minInput.value = `${this.minPrice}`;
|
|
72
|
+
this.maxInput.value = `${this.maxPrice}`;
|
|
73
|
+
this.changedEventHandler(event);
|
|
30
74
|
}
|
|
31
|
-
async
|
|
75
|
+
async changedEventHandler(event, isMin = false) {
|
|
32
76
|
let value = event ? event.target.value * 1 : null;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
77
|
+
if (isMin) {
|
|
78
|
+
this.minInputValidation(value);
|
|
79
|
+
this.minthumb = ((this.minPrice - this.min) / (this.max - this.min)) * 100;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.maxInputValidation(value);
|
|
83
|
+
this.maxthumb = 100 - (((this.maxPrice - this.min) / (this.max - this.min)) * 100);
|
|
84
|
+
}
|
|
85
|
+
this.isReady && this.changed.emit({
|
|
86
|
+
event: event,
|
|
87
|
+
option: this.option,
|
|
88
|
+
value: { max: this.maxPrice, min: this.minPrice }
|
|
89
|
+
});
|
|
37
90
|
}
|
|
38
|
-
|
|
39
|
-
if (value && (value > this.max || value > this.maxPrice))
|
|
91
|
+
minInputValidation(value) {
|
|
92
|
+
if (value && (value > this.max || value > this.maxPrice)) {
|
|
93
|
+
// this.minPrice = this.maxPrice;
|
|
40
94
|
return;
|
|
41
|
-
|
|
95
|
+
}
|
|
96
|
+
if (value < this.min) {
|
|
42
97
|
this.minPrice = this.min;
|
|
98
|
+
return;
|
|
43
99
|
}
|
|
44
|
-
|
|
45
|
-
|
|
100
|
+
if (value) {
|
|
101
|
+
this.minPrice = value;
|
|
46
102
|
}
|
|
47
103
|
}
|
|
48
|
-
|
|
49
|
-
if (value && (value < this.min || value < this.minPrice))
|
|
104
|
+
maxInputValidation(value) {
|
|
105
|
+
if (value && (value < this.min || value < this.minPrice)) {
|
|
106
|
+
// this.maxPrice = this.minPrice;
|
|
50
107
|
return;
|
|
51
|
-
|
|
108
|
+
}
|
|
109
|
+
if (value > this.max) {
|
|
52
110
|
this.maxPrice = this.max;
|
|
111
|
+
return;
|
|
53
112
|
}
|
|
54
|
-
|
|
55
|
-
|
|
113
|
+
if (value) {
|
|
114
|
+
this.maxPrice = value;
|
|
56
115
|
}
|
|
57
116
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
117
|
+
isChecked(option) {
|
|
118
|
+
if (option == Math.floor(this.max / 100)) {
|
|
119
|
+
return this.minPrice == 0 && this.maxPrice == option;
|
|
120
|
+
}
|
|
121
|
+
if (option == Math.floor(this.max / 2)) {
|
|
122
|
+
return this.minPrice == this.priceOptions[0] && this.maxPrice == this.priceOptions[2];
|
|
123
|
+
}
|
|
124
|
+
if (option == Math.floor((this.max / 3) * 2)) {
|
|
125
|
+
return this.minPrice == option && this.maxPrice == this.max;
|
|
126
|
+
}
|
|
65
127
|
}
|
|
66
128
|
render() {
|
|
67
|
-
return (h(Host, null,
|
|
129
|
+
return (h(Host, null, this.priceOptions && this.priceOptions.map((option, index) => {
|
|
130
|
+
return h("label", { class: "s-filters-label", htmlFor: `${option}-${index}` }, h("input", { id: `${option}-${index}`, name: "price", type: "radio", checked: this.isChecked(option), class: "s-filters-radio", onChange: e => this.handleMinMaxPrice(e, option) }), this.getPriceLabel(option));
|
|
131
|
+
}), h("div", { class: "flex justify-center items-center" }, h("div", { class: "relative max-w-xl w-full" }, h("div", { class: "s-price-range-inputs" }, h("div", { class: "s-price-range-relative" }, h("div", { class: "s-price-range-currency" }, " ", salla.config.currency().symbol), h("input", { type: "number", maxlength: "5", ref: el => this.minInput = el, onInput: (event) => this.changedEventHandler(event, true),
|
|
132
|
+
// value={this.minPrice}
|
|
133
|
+
placeholder: "\u0645\u0646", class: "s-price-range-number-input" })), h("div", { class: "s-price-range-gray-text" }, " -"), h("div", { class: "s-price-range-relative" }, h("div", { class: "s-price-range-currency" }, " ", salla.config.currency().symbol), h("input", { type: "number", maxlength: "5", placeholder: "\u0627\u0644\u0649", ref: el => this.maxInput = el, onInput: (event) => this.changedEventHandler(event),
|
|
134
|
+
// value={this.maxPrice}
|
|
135
|
+
class: "s-price-range-number-input", "aria-describedby": "price-currency" })))))));
|
|
68
136
|
}
|
|
69
137
|
componentDidLoad() {
|
|
70
|
-
|
|
71
|
-
this.
|
|
72
|
-
|
|
138
|
+
var _a;
|
|
139
|
+
if (this.filtersData && ((_a = this.filtersData) === null || _a === void 0 ? void 0 : _a.price)) {
|
|
140
|
+
this.minPrice = this.filtersData.price.min;
|
|
141
|
+
this.maxPrice = this.filtersData.price.max;
|
|
142
|
+
this.maxInput.value = `${this.maxPrice}`;
|
|
143
|
+
this.minInput.value = `${this.minPrice}`;
|
|
144
|
+
}
|
|
73
145
|
this.isReady = true;
|
|
74
146
|
}
|
|
75
147
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"salla-price-range.entry.js","mappings":";;;;;AAAA,MAAM,kBAAkB,GAAG,ynBAAynB;;MCMvoB,eAAe;;;;;oBACQ,IAAI;oBACJ,IAAI;eACvB,CAAC;eACD,KAAK;oBAEA,CAAC;oBACD,CAAC;;EAUrB,iBAAiB;IACf,IAAI,CAAC,UAAU,EAAE,CAAC;IAClB,IAAI,CAAC,UAAU,EAAE,CAAC;GACnB;EAGD,MAAM,UAAU,CAAC,KAAK,GAAG,IAAI;IAC3B,IAAI,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAA;IACjD,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;IAC3E,IAAI,CAAC,gBAAgB,EAAE,CAAA;IAEvB,IAAI,CAAC,OAAO,IAAI,IAAI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IAEd,IAAI,CAAC,gBAAgB,EAAE,CAAA;IACvB,IAAI,CAAC,iBAAiB,EAAE,CAAA;IACxB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;GACrB;;;;;;","names":[],"sources":["./src/components/salla-price-range/salla-price-range.scss?tag=salla-price-range","./src/components/salla-price-range/salla-price-range.tsx"],"sourcesContent":[":host {\n display: block;\n}\n\n\n.rtl, [dir=\"rtl\"] {\n .rtl-range-slider {\n transform: rotateY(180deg);\n }\n\n .rtl-range-numbers{\n flex-direction: row-reverse;\n }\n\n .form-select, select{\n background-position: left 0.5rem center;\n padding-right: 12px;\n } \n\n // divide\n.menu-divide {\n li {\n &:not(:last-child) {\n &:after {\n left: 0;\n right: auto;\n }\n }\n }\n}\n}\n\ninput[type=range]::-webkit-slider-thumb {\n pointer-events: all;\n width: 24px;\n height: 24px;\n -webkit-appearance: none;\n}\n\n[type='checkbox']:checked{\n background-size: 80%;\n}","import {Component, Host, h, Method, State, Prop, Event, EventEmitter} from '@stencil/core';\n\n@Component({\n tag: 'salla-price-range',\n styleUrl: 'salla-price-range.scss',\n})\nexport class SallaPriceRange {\n @Prop({mutable: true}) minPrice = 1000;\n @Prop({mutable: true}) maxPrice = 5000;\n @State() min = 0;\n @State() max = 10000;\n\n @State() minthumb = 0;\n @State() maxthumb = 0;\n\n @Event() minPriceSelected: EventEmitter<number>;\n @Event() maxPriceSelected: EventEmitter<number>;\n\n isReady: Boolean;\n rightHandle: HTMLDivElement;\n leftHandle: HTMLDivElement;\n activeBar: HTMLDivElement;\n\n componentWillLoad() {\n this.minTrigger();\n this.maxTrigger();\n }\n\n @Method()\n async minTrigger(event = null) {\n let value = event ? event.target.value * 1 : null\n this.minInputValidation(value);\n this.minthumb = ((this.minPrice - this.min) / (this.max - this.min)) * 100;\n this.changeLeftHandle()\n \n this.isReady && this.minPriceSelected.emit(value);\n }\n\n @Method()\n async maxTrigger(event = null) {\n let value = event ? event.target.value * 1 : null\n this.maxInputValidation(value)\n this.maxthumb = 100 - (((this.maxPrice - this.min) / (this.max - this.min)) * 100);\n this.changeRightHandle()\n \n this.isReady && this.maxPriceSelected.emit(value);\n }\n\n @Method()\n async minInputValidation(value) {\n if (value && (value > this.max || value > this.maxPrice)) return;\n else if (value < this.min) {\n this.minPrice = this.min;\n } else {\n value && (this.minPrice = value)\n }\n }\n\n @Method()\n async maxInputValidation(value) {\n if (value && (value < this.min || value < this.minPrice)) return;\n else if (value > this.max) {\n this.maxPrice = this.max;\n } else {\n value && (this.maxPrice = value)\n }\n }\n\n @Method()\n async changeRightHandle() {\n this.rightHandle && (this.rightHandle.style.right = `${this.maxthumb}%`);\n this.activeBar && (this.activeBar.style.right = `${this.maxthumb}%`);\n }\n\n @Method()\n async changeLeftHandle() {\n this.leftHandle && (this.leftHandle.style.left = `${this.minthumb}%`);\n this.activeBar && (this.activeBar.style.left = `${this.minthumb}%`);\n }\n\n\n render() {\n return (\n <Host>\n <div style={{direction: 'ltr'}} class=\"flex justify-center items-center\">\n <div class=\"relative max-w-xl w-full\">\n <div class=\"rtl-range-slider\">\n <input\n type=\"range\"\n step=\"100\"\n min={this.min} max={this.max}\n onInput={(event) => this.minTrigger(event)}\n value={this.minPrice}\n class=\"s-price-range-input\"\n />\n\n <input\n type=\"range\"\n step=\"100\"\n min={this.min}\n max={this.max}\n onInput={(event) => this.maxTrigger(event)}\n value={this.maxPrice}\n class=\"s-price-range-input\"\n />\n\n <div class=\"s-price-range-bar-container\">\n <div class=\"s-price-range-bar\"/>\n <div class=\"s-price-range-active-bar\" ref={(el) => this.activeBar = el}/>\n <div class=\"s-price-range-left-handle\" ref={(el) => this.leftHandle = el}/>\n <div class=\"s-price-range-right-handle\" ref={(el) => this.rightHandle = el}/>\n </div>\n\n </div>\n\n\n <div class=\"s-price-range-inputs\">\n <div class=\"s-price-range-relative\">\n <div class=\"s-price-range-currency\"> {salla.config.currency().symbol}</div>\n <input\n type=\"number\"\n maxlength=\"5\"\n onInput={(event) => this.minTrigger(event)}\n value={this.minPrice}\n class=\"s-price-range-number-input\"\n />\n </div>\n\n <div class=\"s-price-range-gray-text\"> - </div>\n <div class=\"s-price-range-relative\">\n <div class=\"s-price-range-currency\"> {salla.config.currency().symbol}</div>\n <input type=\"number\" maxlength=\"5\"\n onInput={(event) => this.maxTrigger(event)}\n value={this.maxPrice}\n class=\"s-price-range-number-input\" placeholder=\"0.00\" aria-describedby=\"price-currency\"/>\n </div>\n\n </div>\n\n </div>\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n // this.max=this.maxPrice;\n this.changeLeftHandle()\n this.changeRightHandle()\n this.isReady = true;\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"salla-price-range.entry.js","mappings":";;;;;AAAA,MAAM,kBAAkB,GAAG,ynBAAynB;;MCOvoB,eAAe;EAC1B;;;oBAGoC,IAAI;oBACJ,IAAI;;;eAGzB,CAAC;eACD,KAAK;oBAEA,CAAC;oBACD,CAAC;;IAVnB,IAAI,CAAC,oBAAoB,EAAE,CAAC;GAC7B;EAsBD,MAAM,KAAK;;;IAET,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,GAAG,CAAA,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,MAAM,0CAAE,GAAG,KAAI,CAAC,EAAE,CAAC;IACzD,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;GACrC;EAEO,oBAAoB;IAC1B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC;IAC3B,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC;IAC1C,IAAI,OAAO,GAAG,CAAC,EAAE;MACf,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC,CAAC;KACtC;IACD,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IACxC,IAAI,OAAO,GAAG,IAAI,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,EAAC,wBAAwB,IACjC,WAAK,KAAK,EAAC,wBAAwB,SAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAO,EAC3E,aAAO,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,GAAG,EAChC,WAAW,EAAC,oBAAK,EACjB,GAAG,EAAE,EAAE,IAAI,IAAI,CAAC,QAAQ,GAAG,EAAE,EAC7B,OAAO,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC;;MAEnD,KAAK,EAAC,4BAA4B,sBAAkB,gBAAgB,GAAG,CACrE,CACF,CACF,CACF,CACD,EACP;GACH;EAED,gBAAgB;;IACd,IAAI,IAAI,CAAC,WAAW,KAAI,MAAA,IAAI,CAAC,WAAW,0CAAE,KAAK,CAAA,EAAE;MAC/C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC;MAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC;MAC3C,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;MACzC,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;KAC1C;IACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;GACrB;;;;;;","names":[],"sources":["./src/components/salla-price-range/salla-price-range.scss?tag=salla-price-range","./src/components/salla-price-range/salla-price-range.tsx"],"sourcesContent":[":host {\n display: block;\n}\n\n\n.rtl, [dir=\"rtl\"] {\n .rtl-range-slider {\n transform: rotateY(180deg);\n }\n\n .rtl-range-numbers{\n flex-direction: row-reverse;\n }\n\n .form-select, select{\n background-position: left 0.5rem center;\n padding-right: 12px;\n } \n\n // divide\n.menu-divide {\n li {\n &:not(:last-child) {\n &:after {\n left: 0;\n right: auto;\n }\n }\n }\n}\n}\n\ninput[type=range]::-webkit-slider-thumb {\n pointer-events: all;\n width: 24px;\n height: 24px;\n -webkit-appearance: none;\n}\n\n[type='checkbox']:checked{\n background-size: 80%;\n}","import { Component, Host, h, State, Prop, Event, Method } from '@stencil/core';\nimport { Filter } from \"../salla-filters/interfaces\";\n\n@Component({\n tag: 'salla-price-range',\n styleUrl: 'salla-price-range.scss',\n})\nexport class SallaPriceRange {\n constructor() {\n this.generatePriceOptions();\n }\n @Prop({ mutable: true }) minPrice = 1000;\n @Prop({ mutable: true }) maxPrice = 5000;\n @Prop({ reflect: true }) option: Filter;\n @Prop({ reflect: true }) filtersData: any;\n @State() min = 0;\n @State() max = 10000;\n\n @State() minthumb = 0;\n @State() maxthumb = 0;\n @State() priceOptions: any;\n\n @Event() changed: any;\n\n isReady: Boolean;\n rightHandle: HTMLDivElement;\n leftHandle: HTMLDivElement;\n activeBar: HTMLDivElement;\n minInput: HTMLInputElement;\n maxInput: HTMLInputElement;\n\n @Method()\n async reset() {\n //@ts-ignore\n this.minInput.value = `${this.option?.values?.min || 0}`;\n this.maxInput.value = `${this.max}`;\n }\n\n private generatePriceOptions() {\n const MAX_PRICE = this.max;\n let option1 = Math.floor(MAX_PRICE / 100);\n if (option1 < 1) {\n option1 = Math.floor(MAX_PRICE / 10);\n }\n let option2 = Math.floor(MAX_PRICE / 2);\n let option3 = Math.floor((MAX_PRICE / 3) * 2);\n this.priceOptions = [option1, option2, option3];\n\n // to be removed\n console.log(`Price options for max price ${MAX_PRICE}: ${this.priceOptions.join(', ')}`);\n }\n private getPriceLabel(price) {\n if (price == Math.floor(this.max / 100)) {\n return `اقل من ${salla.money(price)}`;\n } else if (price == Math.floor(this.max / 2)) {\n return `${salla.money(this.priceOptions[0])} الى ${salla.money(this.priceOptions[2])}`;\n } else {\n return `أكثر من ${salla.money(price)}`;\n }\n }\n\n private handleMinMaxPrice(event: Event, option: string): void {\n const [firstOption, secondOption, thirdOption] = this.priceOptions;\n switch (option) {\n case firstOption:\n this.minPrice = 0;\n this.maxPrice = firstOption;\n break;\n case secondOption:\n this.minPrice = firstOption;\n this.maxPrice = thirdOption;\n break;\n case thirdOption:\n this.minPrice = thirdOption;\n this.maxPrice = this.max;\n break;\n default:\n throw new Error(`Invalid price option: ${option}`);\n }\n\n // Update the input values\n this.minInput.value = `${this.minPrice}`;\n this.maxInput.value = `${this.maxPrice}`;\n this.changedEventHandler(event);\n }\n\n private async changedEventHandler(event, isMin = false) {\n\n let value = event ? event.target.value * 1 : null\n if (isMin) {\n this.minInputValidation(value);\n this.minthumb = ((this.minPrice - this.min) / (this.max - this.min)) * 100;\n } else {\n this.maxInputValidation(value)\n this.maxthumb = 100 - (((this.maxPrice - this.min) / (this.max - this.min)) * 100);\n }\n\n\n this.isReady && this.changed.emit({\n event: event,\n option: this.option,\n value: { max: this.maxPrice, min: this.minPrice }\n })\n }\n\n\n minInputValidation(value) {\n if (value && (value > this.max || value > this.maxPrice)) {\n // this.minPrice = this.maxPrice;\n return;\n }\n\n if (value < this.min) {\n this.minPrice = this.min;\n return;\n }\n\n if (value) {\n this.minPrice = value;\n }\n }\n\n maxInputValidation(value) {\n if (value && (value < this.min || value < this.minPrice)) {\n // this.maxPrice = this.minPrice;\n return;\n }\n if (value > this.max) {\n this.maxPrice = this.max;\n return;\n }\n\n if (value) {\n this.maxPrice = value;\n }\n }\n private isChecked(option) {\n if (option == Math.floor(this.max / 100)) {\n return this.minPrice == 0 && this.maxPrice == option;\n }\n if (option == Math.floor(this.max / 2)) {\n return this.minPrice == this.priceOptions[0] && this.maxPrice == this.priceOptions[2];\n }\n if (option == Math.floor((this.max / 3) * 2)) {\n\n return this.minPrice == option && this.maxPrice == this.max;\n }\n }\n\n\n render() {\n return (\n <Host>\n {\n this.priceOptions && this.priceOptions.map((option, index) => {\n return <label class=\"s-filters-label\" htmlFor={`${option}-${index}`}>\n <input\n id={`${option}-${index}`}\n name=\"price\"\n type=\"radio\"\n checked={this.isChecked(option)}\n class=\"s-filters-radio\"\n onChange={e => this.handleMinMaxPrice(e, option)}\n />\n {this.getPriceLabel(option)}\n </label>\n })\n }\n\n\n <div class=\"flex justify-center items-center\">\n <div class=\"relative max-w-xl w-full\">\n <div class=\"s-price-range-inputs\">\n <div class=\"s-price-range-relative\">\n <div class=\"s-price-range-currency\"> {salla.config.currency().symbol}</div>\n <input\n type=\"number\"\n maxlength=\"5\"\n ref={el => this.minInput = el}\n onInput={(event) => this.changedEventHandler(event, true)}\n // value={this.minPrice}\n placeholder=\"من\"\n class=\"s-price-range-number-input\"\n />\n </div>\n\n <div class=\"s-price-range-gray-text\"> -</div>\n <div class=\"s-price-range-relative\">\n <div class=\"s-price-range-currency\"> {salla.config.currency().symbol}</div>\n <input type=\"number\" maxlength=\"5\"\n placeholder=\"الى\"\n ref={el => this.maxInput = el}\n onInput={(event) => this.changedEventHandler(event)}\n // value={this.maxPrice}\n class=\"s-price-range-number-input\" aria-describedby=\"price-currency\" />\n </div>\n </div>\n </div>\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n if (this.filtersData && this.filtersData?.price) {\n this.minPrice = this.filtersData.price.min;\n this.maxPrice = this.filtersData.price.max;\n this.maxInput.value = `${this.maxPrice}`;\n this.minInput.value = `${this.minPrice}`;\n }\n this.isReady = true;\n }\n}\n"],"version":3}
|