@shoper/phoenix_design_system 1.10.0 → 1.10.1
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/build/cjs/packages/phoenix/src/components/dropdown/dropdown.js +1 -1
- package/build/cjs/packages/phoenix/src/components/form/select/model/select_option_mapper.js +4 -4
- package/build/cjs/packages/phoenix/src/components/form/select/select.js +68 -36
- package/build/cjs/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/messages/base_message.js +1 -2
- package/build/cjs/packages/phoenix/src/components/messages/base_message.js.map +1 -1
- package/build/cjs/packages/phoenix/src/controllers/relative_position_controller/relative_position_controller.js +2 -2
- package/build/cjs/packages/phoenix/src/controllers/relative_position_controller/relative_position_controller_constants.js +0 -43
- package/build/cjs/packages/phoenix/src/controllers/relative_position_controller/relative_position_controller_constants.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown.js +2 -2
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_types.d.ts +1 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_types.js +1 -1
- package/build/esm/packages/phoenix/src/components/dropdown/dropdown_types.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/select/model/select_option.d.ts +1 -1
- package/build/esm/packages/phoenix/src/components/form/select/model/select_option_mapper.js +4 -4
- package/build/esm/packages/phoenix/src/components/form/select/model/{select_option_constants.d.ts → select_option_types.d.ts} +2 -1
- package/build/esm/packages/phoenix/src/components/form/select/model/select_option_types.js +2 -0
- package/build/esm/packages/phoenix/src/components/form/select/model/select_option_types.js.map +1 -0
- package/build/esm/packages/phoenix/src/components/form/select/select.d.ts +6 -0
- package/build/esm/packages/phoenix/src/components/form/select/select.js +67 -35
- package/build/esm/packages/phoenix/src/components/form/select/select.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/messages/base_message.d.ts +1 -1
- package/build/esm/packages/phoenix/src/components/messages/base_message.js +1 -2
- package/build/esm/packages/phoenix/src/components/messages/base_message.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_controller.d.ts +2 -1
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_controller.js +2 -2
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_controller_constants.d.ts +0 -55
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_controller_constants.js +1 -39
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_controller_constants.js.map +1 -1
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_controller_types.d.ts +2 -12
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_controller_types.js +1 -1
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_controller_types.js.map +1 -1
- package/build/esm/packages/phoenix/src/index.d.ts +1 -0
- package/package.json +1 -1
- package/build/cjs/packages/phoenix/src/controllers/relative_position_controller/relative_position_calculator.js +0 -229
- package/build/cjs/packages/phoenix/src/controllers/relative_position_controller/relative_position_calculator.js.map +0 -1
- package/build/esm/packages/phoenix/src/components/form/select/model/select_option_constants.js +0 -2
- package/build/esm/packages/phoenix/src/components/form/select/model/select_option_constants.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_calculator.d.ts +0 -24
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_calculator.js +0 -225
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_calculator.js.map +0 -1
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_calculator_types.d.ts +0 -44
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_calculator_types.js +0 -4
- package/build/esm/packages/phoenix/src/controllers/relative_position_controller/relative_position_calculator_types.js.map +0 -1
|
@@ -23,7 +23,7 @@ exports.HDropdown = HDropdown_1 = class HDropdown extends phoenix_light_lit_elem
|
|
|
23
23
|
constructor() {
|
|
24
24
|
super();
|
|
25
25
|
this.opened = false;
|
|
26
|
-
this.direction =
|
|
26
|
+
this.direction = utilities.DIRECTIONS.bottomCenter;
|
|
27
27
|
this.toggleOnHover = false;
|
|
28
28
|
this.name = '';
|
|
29
29
|
this.transition = 'direction';
|
|
@@ -7,19 +7,19 @@ var select_option = require('./select_option.js');
|
|
|
7
7
|
|
|
8
8
|
class SelectOptionMapper {
|
|
9
9
|
static toModel($option) {
|
|
10
|
-
|
|
11
|
-
const
|
|
10
|
+
const $optionContent = $option.querySelector(select_components_constatns.SELECT_RELATED_COMPONENTS_NAMES.optionContent);
|
|
11
|
+
const optionContentText = ($optionContent === null || $optionContent === void 0 ? void 0 : $optionContent.textContent) || ($optionContent === null || $optionContent === void 0 ? void 0 : $optionContent.innerText);
|
|
12
12
|
const value = $option.getAttribute('value');
|
|
13
13
|
if (!value)
|
|
14
14
|
throw new Error('h-option must contain a unique value');
|
|
15
|
-
if (!
|
|
15
|
+
if (!optionContentText)
|
|
16
16
|
throw new Error('h-options must contains a h-option-content element inside');
|
|
17
17
|
return select_option.SelectOption.create({
|
|
18
18
|
value,
|
|
19
19
|
disabled: $option.hasAttribute('disabled'),
|
|
20
20
|
hidden: $option.hasAttribute('hidden'),
|
|
21
21
|
inactive: $option.hasAttribute('inactive'),
|
|
22
|
-
content:
|
|
22
|
+
content: optionContentText,
|
|
23
23
|
selected: $option.hasAttribute('selected')
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -11,7 +11,8 @@ var decorators_js = require('@lit/reactive-element/decorators.js');
|
|
|
11
11
|
var select_components_constatns = require('./components/select_components_constatns.js');
|
|
12
12
|
var observer = require('../../../core/classes/observer/observer.js');
|
|
13
13
|
var icon = require('../../icon/icon.js');
|
|
14
|
-
var select_option = require('./components/option/select_option.js');
|
|
14
|
+
var select_option$1 = require('./components/option/select_option.js');
|
|
15
|
+
var select_option = require('./model/select_option.js');
|
|
15
16
|
var select_constants = require('./select_constants.js');
|
|
16
17
|
var observable_directive = require('../../../directives/observable_directive.js');
|
|
17
18
|
var select_toggler = require('./components/toggler/select_toggler.js');
|
|
@@ -27,6 +28,7 @@ var multi_select_controller = require('./controllers/multi_select_controller.js'
|
|
|
27
28
|
var select_utils = require('./select_utils.js');
|
|
28
29
|
var select_controller = require('./controllers/select_controller.js');
|
|
29
30
|
var select_option_mapper = require('./model/select_option_mapper.js');
|
|
31
|
+
var repeat = require('lit/directives/repeat');
|
|
30
32
|
|
|
31
33
|
exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
32
34
|
constructor() {
|
|
@@ -37,6 +39,7 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
37
39
|
this.offset = 2;
|
|
38
40
|
this.searchDisabled = false;
|
|
39
41
|
this.type = select_constants.SELECT_TYPES.select;
|
|
42
|
+
this.noDeselect = false;
|
|
40
43
|
this._searchValue = '';
|
|
41
44
|
this._$options = {};
|
|
42
45
|
this._$dropdown = ref_js.createRef();
|
|
@@ -44,6 +47,40 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
44
47
|
this._$optionsList = ref_js.createRef();
|
|
45
48
|
this._$dropdownContent = ref_js.createRef();
|
|
46
49
|
this._selectContext = new context_provider_controller.ContextProviderController(this);
|
|
50
|
+
this._updateOptions = () => {
|
|
51
|
+
const $options = this._getOptions();
|
|
52
|
+
this._$options = $options.reduce((acc, $option) => {
|
|
53
|
+
const value = $option.getAttribute('value');
|
|
54
|
+
if (!value)
|
|
55
|
+
throw Error('Select option must hava a value');
|
|
56
|
+
if (acc[value] !== undefined)
|
|
57
|
+
throw Error('Select options must hava a unique values.');
|
|
58
|
+
return {
|
|
59
|
+
...acc,
|
|
60
|
+
[value]: $option
|
|
61
|
+
};
|
|
62
|
+
}, {});
|
|
63
|
+
const options = $options.map(select_option_mapper.SelectOptionMapper.toModel);
|
|
64
|
+
this._selectController.options$.notify(options);
|
|
65
|
+
if (options.length)
|
|
66
|
+
this._selectController.selectedOptions$.notify(options.filter((option) => option.selected));
|
|
67
|
+
};
|
|
68
|
+
this._getOptions = () => {
|
|
69
|
+
let $options;
|
|
70
|
+
if (this.optionsList) {
|
|
71
|
+
$options = this.optionsList.map(option => {
|
|
72
|
+
return select_utils.SelectControlUtils.createHTMLOption(select_option.SelectOption.create(option));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
$options = this.hasSlot(select_constants.SELECT_SLOT_NAMES.content)
|
|
77
|
+
? this.getSlot(select_constants.SELECT_SLOT_NAMES.content)
|
|
78
|
+
.map((litElement) => litElement.values[0])
|
|
79
|
+
.filter((element) => element instanceof select_option$1.HOption)
|
|
80
|
+
: Array.from(this.querySelectorAll(select_components_constatns.SELECT_RELATED_COMPONENTS_NAMES.option));
|
|
81
|
+
}
|
|
82
|
+
return $options;
|
|
83
|
+
};
|
|
47
84
|
this._handleOptionDeselect = (event) => {
|
|
48
85
|
const selectedOption = this._selectController.getOption(event.detail);
|
|
49
86
|
if (!selectedOption)
|
|
@@ -143,6 +180,9 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
143
180
|
this.classList.remove(select_constants.SELECT_CSS_CLASSES.selectOpened);
|
|
144
181
|
}
|
|
145
182
|
}
|
|
183
|
+
if (changedProperties.has('optionsList')) {
|
|
184
|
+
this._updateOptions();
|
|
185
|
+
}
|
|
146
186
|
if (this._$optionsList.value && !this._listBoxController)
|
|
147
187
|
this._listBoxController = new list_box_keyboard_controller.ListBoxKeyboardController({
|
|
148
188
|
host: this,
|
|
@@ -163,28 +203,9 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
163
203
|
this._selectController = this.multiple ? new multi_select_controller.MultiSelectController({ host: this }) : new select_controller.SelectController({ host: this });
|
|
164
204
|
this._selectContext.provide(select_constants.SELECT_CONTEXTS.selectedOptions$, this._selectController.selectedOptions$);
|
|
165
205
|
this._selectContext.provide(select_constants.SELECT_CONTEXTS.isMultiselect, this.multiple);
|
|
166
|
-
const $options = this.hasSlot(select_constants.SELECT_SLOT_NAMES.content)
|
|
167
|
-
? this.getSlot(select_constants.SELECT_SLOT_NAMES.content)
|
|
168
|
-
.map((litElement) => litElement.values[0])
|
|
169
|
-
.filter((element) => element instanceof select_option.HOption)
|
|
170
|
-
: Array.from(this.querySelectorAll(select_components_constatns.SELECT_RELATED_COMPONENTS_NAMES.option));
|
|
171
206
|
this._optionsObserver = new observer.Observer((selectedOptions) => this._updateOptionsView(selectedOptions));
|
|
172
207
|
this._selectController.options$.subscribe(this._optionsObserver);
|
|
173
|
-
this.
|
|
174
|
-
const value = $option.getAttribute('value');
|
|
175
|
-
if (!value)
|
|
176
|
-
throw Error('Select option must hava a value');
|
|
177
|
-
if (acc[value] !== undefined)
|
|
178
|
-
throw Error('Select options must hava a unique values.');
|
|
179
|
-
return {
|
|
180
|
-
...acc,
|
|
181
|
-
[value]: $option
|
|
182
|
-
};
|
|
183
|
-
}, {});
|
|
184
|
-
const options = $options.map(select_option_mapper.SelectOptionMapper.toModel);
|
|
185
|
-
this._selectController.options$.notify(options);
|
|
186
|
-
if (options.length)
|
|
187
|
-
this._selectController.selectedOptions$.notify(options.filter((option) => option.selected));
|
|
208
|
+
this._updateOptions();
|
|
188
209
|
this._setupEvents();
|
|
189
210
|
}
|
|
190
211
|
attributeChangedCallback(name, _old, value) {
|
|
@@ -224,7 +245,7 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
224
245
|
const option = this._selectController.getOption(value);
|
|
225
246
|
if (!option)
|
|
226
247
|
return;
|
|
227
|
-
this._selectController.toggle(option);
|
|
248
|
+
this.noDeselect ? this._selectController.select(option) : this._selectController.toggle(option);
|
|
228
249
|
if (!this.multiple)
|
|
229
250
|
this._closeSelect();
|
|
230
251
|
this._dispatchChangeEvent();
|
|
@@ -257,6 +278,11 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
257
278
|
_searchNoResult() {
|
|
258
279
|
return Boolean(!this._selectController.visibleOptionsCount && Object.keys(this._$options).length);
|
|
259
280
|
}
|
|
281
|
+
_renderOption(option) {
|
|
282
|
+
const fragment = document.createDocumentFragment();
|
|
283
|
+
fragment.appendChild(option);
|
|
284
|
+
return fragment;
|
|
285
|
+
}
|
|
260
286
|
render() {
|
|
261
287
|
var _a;
|
|
262
288
|
const options = (_a = this._selectController.options$.getValue()) !== null && _a !== void 0 ? _a : [];
|
|
@@ -292,20 +318,18 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
|
|
|
292
318
|
@selectSearch.search=${this._handleSearch}
|
|
293
319
|
></h-select-search>`
|
|
294
320
|
: lit.nothing}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
`
|
|
308
|
-
: lit.nothing}
|
|
321
|
+
|
|
322
|
+
<h-options
|
|
323
|
+
class="${select_constants.SELECT_CSS_CLASSES.selectOptions} ${this._searchNoResult()
|
|
324
|
+
? select_constants.SELECT_CSS_CLASSES.selectOptionsEmpty
|
|
325
|
+
: ''}"
|
|
326
|
+
${ref_js.ref(this._$optionsList)}
|
|
327
|
+
@selectOptions.clicked=${this._handleOptionClicked}
|
|
328
|
+
@selectOptions.updated=${this._handleOptionUpdated}
|
|
329
|
+
>
|
|
330
|
+
${this._$options ? repeat.repeat(Object.values(this._$options), (option) => option.value, (option) => this._renderOption(option)) : lit.nothing}
|
|
331
|
+
</h-options>
|
|
332
|
+
|
|
309
333
|
${this._searchNoResult()
|
|
310
334
|
? lit.html ` <div>
|
|
311
335
|
<p class=${select_constants.SELECT_CSS_CLASSES.selectNoResult}>
|
|
@@ -379,6 +403,14 @@ tslib_es6.__decorate([
|
|
|
379
403
|
decorators_js.property({ type: Boolean }),
|
|
380
404
|
tslib_es6.__metadata("design:type", Boolean)
|
|
381
405
|
], exports.HSelect.prototype, "required", void 0);
|
|
406
|
+
tslib_es6.__decorate([
|
|
407
|
+
decorators_js.property({ type: Array }),
|
|
408
|
+
tslib_es6.__metadata("design:type", Array)
|
|
409
|
+
], exports.HSelect.prototype, "optionsList", void 0);
|
|
410
|
+
tslib_es6.__decorate([
|
|
411
|
+
decorators_js.property({ type: Boolean, attribute: 'no-deselect' }),
|
|
412
|
+
tslib_es6.__metadata("design:type", Boolean)
|
|
413
|
+
], exports.HSelect.prototype, "noDeselect", void 0);
|
|
382
414
|
tslib_es6.__decorate([
|
|
383
415
|
decorators.state(),
|
|
384
416
|
tslib_es6.__metadata("design:type", String)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -7,7 +7,6 @@ var decorators = require('lit/decorators');
|
|
|
7
7
|
var utilities = require('@dreamcommerce/utilities');
|
|
8
8
|
var phoenix_light_lit_element = require('../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
|
|
9
9
|
var keystrokes_controller = require('../../controllers/keystrokes_controller/keystrokes_controller.js');
|
|
10
|
-
var relative_position_controller_constants = require('../../controllers/relative_position_controller/relative_position_controller_constants.js');
|
|
11
10
|
var portal_constants = require('../portal/portal_constants.js');
|
|
12
11
|
var click_outside_controller = require('../../controllers/click_outside_controller/click_outside_controller.js');
|
|
13
12
|
var relative_position_controller = require('../../controllers/relative_position_controller/relative_position_controller.js');
|
|
@@ -18,7 +17,7 @@ class BaseMessage extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
|
18
17
|
super();
|
|
19
18
|
this.opened = false;
|
|
20
19
|
this.portalTarget = base_message_constants.DEFAULT_MESSAGE_PORTAL_NAME;
|
|
21
|
-
this.direction =
|
|
20
|
+
this.direction = utilities.DIRECTIONS.topCenter;
|
|
22
21
|
this.offset = base_message_constants.DEFAULT_MESSAGE_OFFSET;
|
|
23
22
|
this._setupEventListeners = () => {
|
|
24
23
|
this.addEventListener('mouseenter', this.open);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
|
|
6
6
|
require('lit');
|
|
7
|
+
var utilities = require('@dreamcommerce/utilities');
|
|
7
8
|
var global_constants = require('../../global_constants.js');
|
|
8
9
|
var relative_position_controller_constants = require('./relative_position_controller_constants.js');
|
|
9
|
-
var relative_position_calculator = require('./relative_position_calculator.js');
|
|
10
10
|
var throttle = require('../../../../../external/lodash/throttle.js');
|
|
11
11
|
|
|
12
12
|
var _RelativePositionController_host, _RelativePositionController_container, _RelativePositionController_direction, _RelativePositionController_nearestScrollableElement, _RelativePositionController_relativeElement, _RelativePositionController_elementToPosition, _RelativePositionController_disablePositioningOnCondition, _RelativePositionController_portalElementsNames, _RelativePositionController_isInitiallyScrollable, _RelativePositionController_initialMaxHeight, _RelativePositionController_initialHeight, _RelativePositionController_calculatedDirection, _RelativePositionController_hasPositioningBeenDisabled, _RelativePositionController_doesCurrentlyHaveShrinkMode, _RelativePositionController_offset, _RelativePositionController_mobileElementPosition, _RelativePositionController_throttledReposition, _RelativePositionController_throttledRepositionForScroll;
|
|
@@ -75,7 +75,7 @@ class RelativePositionController {
|
|
|
75
75
|
const positionElementRect = tslib_es6.__classPrivateFieldGet(this, _RelativePositionController_initialHeight, "f")
|
|
76
76
|
? { ...tslib_es6.__classPrivateFieldGet(this, _RelativePositionController_elementToPosition, "f").getBoundingClientRect().toJSON(), height: tslib_es6.__classPrivateFieldGet(this, _RelativePositionController_initialHeight, "f") }
|
|
77
77
|
: tslib_es6.__classPrivateFieldGet(this, _RelativePositionController_elementToPosition, "f").getBoundingClientRect();
|
|
78
|
-
const position = new
|
|
78
|
+
const position = new utilities.RelativePositionCalculator({
|
|
79
79
|
direction: shouldNotReposition && tslib_es6.__classPrivateFieldGet(this, _RelativePositionController_calculatedDirection, "f") ? tslib_es6.__classPrivateFieldGet(this, _RelativePositionController_calculatedDirection, "f") : tslib_es6.__classPrivateFieldGet(this, _RelativePositionController_direction, "f"),
|
|
80
80
|
relativeElementRect: tslib_es6.__classPrivateFieldGet(this, _RelativePositionController_relativeElement, "f").getBoundingClientRect(),
|
|
81
81
|
positionElementRect,
|
|
@@ -2,44 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const VERTICAL_DIRECTIONS = {
|
|
6
|
-
bottomLeft: 'bottom-left',
|
|
7
|
-
bottomRight: 'bottom-right',
|
|
8
|
-
bottomCenter: 'bottom-center',
|
|
9
|
-
topLeft: 'top-left',
|
|
10
|
-
topRight: 'top-right',
|
|
11
|
-
topCenter: 'top-center'
|
|
12
|
-
};
|
|
13
|
-
const HORIZONTAL_DIRECTIONS = {
|
|
14
|
-
rightTop: 'right-top',
|
|
15
|
-
rightCenter: 'right-center',
|
|
16
|
-
rightBottom: 'right-bottom',
|
|
17
|
-
leftTop: 'left-top',
|
|
18
|
-
leftCenter: 'left-center',
|
|
19
|
-
leftBottom: 'left-bottom'
|
|
20
|
-
};
|
|
21
|
-
const CENTER_DIRECTIONS = {
|
|
22
|
-
centerTop: 'center-top',
|
|
23
|
-
centerRight: 'center-right',
|
|
24
|
-
centerBottom: 'center-bottom',
|
|
25
|
-
centerLeft: 'center-left',
|
|
26
|
-
top: 'top',
|
|
27
|
-
right: 'right',
|
|
28
|
-
bottom: 'bottom',
|
|
29
|
-
left: 'left'
|
|
30
|
-
};
|
|
31
|
-
const DIRECTIONS = {
|
|
32
|
-
...HORIZONTAL_DIRECTIONS,
|
|
33
|
-
...VERTICAL_DIRECTIONS,
|
|
34
|
-
...CENTER_DIRECTIONS
|
|
35
|
-
};
|
|
36
|
-
const CALCULATOR_DIRECTIONS = {
|
|
37
|
-
bottom: 'bottom',
|
|
38
|
-
top: 'top',
|
|
39
|
-
left: 'left',
|
|
40
|
-
right: 'right',
|
|
41
|
-
center: 'center'
|
|
42
|
-
};
|
|
43
5
|
const NON_STATIC_POSITIONS = ['relative', 'absolute', 'fixed', 'sticky'];
|
|
44
6
|
const OVERFLOW_SCROLL = 'scroll';
|
|
45
7
|
const OVERFLOW_AUTO = 'auto';
|
|
@@ -57,12 +19,8 @@ const MOBILE_ELEMENT_POSITIONS = {
|
|
|
57
19
|
right: 'right'
|
|
58
20
|
};
|
|
59
21
|
|
|
60
|
-
exports.CALCULATOR_DIRECTIONS = CALCULATOR_DIRECTIONS;
|
|
61
|
-
exports.CENTER_DIRECTIONS = CENTER_DIRECTIONS;
|
|
62
22
|
exports.DEFAULT_SCROLL_THROTTLE_WAIT_TIME = DEFAULT_SCROLL_THROTTLE_WAIT_TIME;
|
|
63
23
|
exports.DEFAULT_THROTTLE_WAIT_TIME = DEFAULT_THROTTLE_WAIT_TIME;
|
|
64
|
-
exports.DIRECTIONS = DIRECTIONS;
|
|
65
|
-
exports.HORIZONTAL_DIRECTIONS = HORIZONTAL_DIRECTIONS;
|
|
66
24
|
exports.MOBILE_ELEMENT_POSITIONS = MOBILE_ELEMENT_POSITIONS;
|
|
67
25
|
exports.NON_STATIC_POSITIONS = NON_STATIC_POSITIONS;
|
|
68
26
|
exports.OVERFLOW_AUTO = OVERFLOW_AUTO;
|
|
@@ -70,5 +28,4 @@ exports.OVERFLOW_SCROLL = OVERFLOW_SCROLL;
|
|
|
70
28
|
exports.RELATIVE_POSITION_CONTROLLER_EVENTS = RELATIVE_POSITION_CONTROLLER_EVENTS;
|
|
71
29
|
exports.SHRINK_MODE_BOTTOM_MARGIN = SHRINK_MODE_BOTTOM_MARGIN;
|
|
72
30
|
exports.SHRINK_MODE_MIN_HEIGHT = SHRINK_MODE_MIN_HEIGHT;
|
|
73
|
-
exports.VERTICAL_DIRECTIONS = VERTICAL_DIRECTIONS;
|
|
74
31
|
//# sourceMappingURL=relative_position_controller_constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate, __metadata } from '../../../../../external/tslib/tslib.es6.js';
|
|
2
|
-
import { UiDomUtils } from '@dreamcommerce/utilities';
|
|
2
|
+
import { DIRECTIONS, UiDomUtils } from '@dreamcommerce/utilities';
|
|
3
3
|
import { PhoenixLightLitElement } from '../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
|
|
4
4
|
import { phoenixCustomElement } from '../../core/decorators/phoenix_custom_element.js';
|
|
5
5
|
import { property } from '@lit/reactive-element/decorators.js';
|
|
@@ -7,7 +7,7 @@ import { KeystrokesController } from '../../controllers/keystrokes_controller/ke
|
|
|
7
7
|
import { html } from 'lit-html';
|
|
8
8
|
import { BREAKPOINTS, SCROLLABLE_CLASS_NAME } from '../../global_constants.js';
|
|
9
9
|
import { DEFAULT_DROPDOWN_PORTAL_NAME, DROPDOWN_CONTENT_CSS_CLASSES, DROPDOWN_EVENTS, DROPDOWN_CONTAINER_NAME, DROPDOWN_CONTENT_NAME, DROPDOWN_CONTENT_WIDTH, DROPDOWN_TOGGLER_NAME } from './dropdown_constants.js';
|
|
10
|
-
import {
|
|
10
|
+
import { RELATIVE_POSITION_CONTROLLER_EVENTS, DEFAULT_THROTTLE_WAIT_TIME } from '../../controllers/relative_position_controller/relative_position_controller_constants.js';
|
|
11
11
|
import { PORTAL_TARGET_COMPONENT_NAME, PORTAL_TARGET_NAME_PROP } from '../portal/portal_constants.js';
|
|
12
12
|
import { BackdropController } from '../backdrop/controller/backdrop_controller.js';
|
|
13
13
|
import { ClickOutsideController } from '../../controllers/click_outside_controller/click_outside_controller.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Any } from 'ts-toolbelt';
|
|
2
2
|
import { DROPDOWN_CONTENT_WIDTH } from "./dropdown_constants";
|
|
3
|
-
import { VERTICAL_DIRECTIONS } from
|
|
3
|
+
import { VERTICAL_DIRECTIONS } from '@dreamcommerce/utilities';
|
|
4
4
|
export declare type TDropdownSelectors = {
|
|
5
5
|
getDropdownPortalTargetName(): string;
|
|
6
6
|
getDropdownContainerName(): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'ts-toolbelt';
|
|
2
2
|
import '@phoenixRoot/components/dropdown/dropdown_constants';
|
|
3
|
-
import '@
|
|
3
|
+
import '@dreamcommerce/utilities';
|
|
4
4
|
//# sourceMappingURL=dropdown_types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown_types.js","sourceRoot":"","sources":["../../../../../../../src/components/dropdown/dropdown_types.ts"],"names":[],"mappings":"AAAA,OAAoB,aAAa,CAAC;AAClC,OAAuC,qDAAqD,CAAC;AAC7F,OAAoC,
|
|
1
|
+
{"version":3,"file":"dropdown_types.js","sourceRoot":"","sources":["../../../../../../../src/components/dropdown/dropdown_types.ts"],"names":[],"mappings":"AAAA,OAAoB,aAAa,CAAC;AAClC,OAAuC,qDAAqD,CAAC;AAC7F,OAAoC,0BAA0B,CAAC"}
|
|
@@ -3,19 +3,19 @@ import { SelectOption } from './select_option.js';
|
|
|
3
3
|
|
|
4
4
|
class SelectOptionMapper {
|
|
5
5
|
static toModel($option) {
|
|
6
|
-
|
|
7
|
-
const
|
|
6
|
+
const $optionContent = $option.querySelector(SELECT_RELATED_COMPONENTS_NAMES.optionContent);
|
|
7
|
+
const optionContentText = ($optionContent === null || $optionContent === void 0 ? void 0 : $optionContent.textContent) || ($optionContent === null || $optionContent === void 0 ? void 0 : $optionContent.innerText);
|
|
8
8
|
const value = $option.getAttribute('value');
|
|
9
9
|
if (!value)
|
|
10
10
|
throw new Error('h-option must contain a unique value');
|
|
11
|
-
if (!
|
|
11
|
+
if (!optionContentText)
|
|
12
12
|
throw new Error('h-options must contains a h-option-content element inside');
|
|
13
13
|
return SelectOption.create({
|
|
14
14
|
value,
|
|
15
15
|
disabled: $option.hasAttribute('disabled'),
|
|
16
16
|
hidden: $option.hasAttribute('hidden'),
|
|
17
17
|
inactive: $option.hasAttribute('inactive'),
|
|
18
|
-
content:
|
|
18
|
+
content: optionContentText,
|
|
19
19
|
selected: $option.hasAttribute('selected')
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare type
|
|
1
|
+
export declare type TSelectOption = {
|
|
2
2
|
value: string;
|
|
3
3
|
content: string;
|
|
4
4
|
selected?: boolean;
|
|
@@ -6,3 +6,4 @@ export declare type TSelectOptionConstructorOptions = {
|
|
|
6
6
|
hidden?: boolean;
|
|
7
7
|
inactive?: boolean;
|
|
8
8
|
};
|
|
9
|
+
export declare type TSelectOptionConstructorOptions = TSelectOption;
|
package/build/esm/packages/phoenix/src/components/form/select/model/select_option_types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select_option_types.js","sourceRoot":"","sources":["../../../../../../../../../src/components/form/select/model/select_option_types.ts"],"names":[],"mappings":""}
|
|
@@ -3,6 +3,7 @@ import { HOption } from "./components/option/select_option";
|
|
|
3
3
|
import { PhoenixLightLitElement } from "../../../core/phoenix_light_lit_element/phoenix_light_lit_element";
|
|
4
4
|
import { SelectOption } from "./model/select_option";
|
|
5
5
|
import type { TSelectType } from "./select_types";
|
|
6
|
+
import { TSelectOption } from './model/select_option_types';
|
|
6
7
|
export declare class HSelect extends PhoenixLightLitElement {
|
|
7
8
|
private static _components;
|
|
8
9
|
controlName: string;
|
|
@@ -15,6 +16,8 @@ export declare class HSelect extends PhoenixLightLitElement {
|
|
|
15
16
|
searchDisabled: boolean;
|
|
16
17
|
type: TSelectType;
|
|
17
18
|
required: boolean;
|
|
19
|
+
optionsList?: TSelectOption[];
|
|
20
|
+
noDeselect: boolean;
|
|
18
21
|
get selectedIndex(): number;
|
|
19
22
|
set selectedIndex(index: number);
|
|
20
23
|
get selectedOptions(): HOption[];
|
|
@@ -37,6 +40,8 @@ export declare class HSelect extends PhoenixLightLitElement {
|
|
|
37
40
|
private _focusElementAfterSelectOpened;
|
|
38
41
|
connectedCallback(): void;
|
|
39
42
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
43
|
+
private _updateOptions;
|
|
44
|
+
private _getOptions;
|
|
40
45
|
private _setupEvents;
|
|
41
46
|
private _handleOptionDeselect;
|
|
42
47
|
private _updateOptionsView;
|
|
@@ -58,5 +63,6 @@ export declare class HSelect extends PhoenixLightLitElement {
|
|
|
58
63
|
disconnectedCallback(): void;
|
|
59
64
|
private _getClonedPlaceholderElement;
|
|
60
65
|
private _searchNoResult;
|
|
66
|
+
private _renderOption;
|
|
61
67
|
protected render(): TemplateResult;
|
|
62
68
|
}
|
|
@@ -8,6 +8,7 @@ import { SELECT_RELATED_COMPONENTS_NAMES, SELECT_INPUT_PLACEHOLDER_SLOT_NAME, SE
|
|
|
8
8
|
import { Observer } from '../../../core/classes/observer/observer.js';
|
|
9
9
|
import { HIcon } from '../../icon/icon.js';
|
|
10
10
|
import { HOption } from './components/option/select_option.js';
|
|
11
|
+
import { SelectOption } from './model/select_option.js';
|
|
11
12
|
import { SELECT_TYPES, SELECT_SLOT_NAMES, SELECT_CSS_CLASSES, SELECT_CONTEXTS, SELECT_EVENT_NAMES, MIN_NUMBER_OF_OPTIONS_TO_SHOW_SEARCH } from './select_constants.js';
|
|
12
13
|
import { observe } from '../../../directives/observable_directive.js';
|
|
13
14
|
import { HSelectToggler } from './components/toggler/select_toggler.js';
|
|
@@ -23,6 +24,7 @@ import { MultiSelectController } from './controllers/multi_select_controller.js'
|
|
|
23
24
|
import { SelectControlUtils } from './select_utils.js';
|
|
24
25
|
import { SelectController } from './controllers/select_controller.js';
|
|
25
26
|
import { SelectOptionMapper } from './model/select_option_mapper.js';
|
|
27
|
+
import { repeat } from 'lit/directives/repeat';
|
|
26
28
|
|
|
27
29
|
let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
28
30
|
constructor() {
|
|
@@ -33,6 +35,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
33
35
|
this.offset = 2;
|
|
34
36
|
this.searchDisabled = false;
|
|
35
37
|
this.type = SELECT_TYPES.select;
|
|
38
|
+
this.noDeselect = false;
|
|
36
39
|
this._searchValue = '';
|
|
37
40
|
this._$options = {};
|
|
38
41
|
this._$dropdown = createRef();
|
|
@@ -40,6 +43,40 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
40
43
|
this._$optionsList = createRef();
|
|
41
44
|
this._$dropdownContent = createRef();
|
|
42
45
|
this._selectContext = new ContextProviderController(this);
|
|
46
|
+
this._updateOptions = () => {
|
|
47
|
+
const $options = this._getOptions();
|
|
48
|
+
this._$options = $options.reduce((acc, $option) => {
|
|
49
|
+
const value = $option.getAttribute('value');
|
|
50
|
+
if (!value)
|
|
51
|
+
throw Error('Select option must hava a value');
|
|
52
|
+
if (acc[value] !== undefined)
|
|
53
|
+
throw Error('Select options must hava a unique values.');
|
|
54
|
+
return {
|
|
55
|
+
...acc,
|
|
56
|
+
[value]: $option
|
|
57
|
+
};
|
|
58
|
+
}, {});
|
|
59
|
+
const options = $options.map(SelectOptionMapper.toModel);
|
|
60
|
+
this._selectController.options$.notify(options);
|
|
61
|
+
if (options.length)
|
|
62
|
+
this._selectController.selectedOptions$.notify(options.filter((option) => option.selected));
|
|
63
|
+
};
|
|
64
|
+
this._getOptions = () => {
|
|
65
|
+
let $options;
|
|
66
|
+
if (this.optionsList) {
|
|
67
|
+
$options = this.optionsList.map(option => {
|
|
68
|
+
return SelectControlUtils.createHTMLOption(SelectOption.create(option));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
$options = this.hasSlot(SELECT_SLOT_NAMES.content)
|
|
73
|
+
? this.getSlot(SELECT_SLOT_NAMES.content)
|
|
74
|
+
.map((litElement) => litElement.values[0])
|
|
75
|
+
.filter((element) => element instanceof HOption)
|
|
76
|
+
: Array.from(this.querySelectorAll(SELECT_RELATED_COMPONENTS_NAMES.option));
|
|
77
|
+
}
|
|
78
|
+
return $options;
|
|
79
|
+
};
|
|
43
80
|
this._handleOptionDeselect = (event) => {
|
|
44
81
|
const selectedOption = this._selectController.getOption(event.detail);
|
|
45
82
|
if (!selectedOption)
|
|
@@ -139,6 +176,9 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
139
176
|
this.classList.remove(SELECT_CSS_CLASSES.selectOpened);
|
|
140
177
|
}
|
|
141
178
|
}
|
|
179
|
+
if (changedProperties.has('optionsList')) {
|
|
180
|
+
this._updateOptions();
|
|
181
|
+
}
|
|
142
182
|
if (this._$optionsList.value && !this._listBoxController)
|
|
143
183
|
this._listBoxController = new ListBoxKeyboardController({
|
|
144
184
|
host: this,
|
|
@@ -159,28 +199,9 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
159
199
|
this._selectController = this.multiple ? new MultiSelectController({ host: this }) : new SelectController({ host: this });
|
|
160
200
|
this._selectContext.provide(SELECT_CONTEXTS.selectedOptions$, this._selectController.selectedOptions$);
|
|
161
201
|
this._selectContext.provide(SELECT_CONTEXTS.isMultiselect, this.multiple);
|
|
162
|
-
const $options = this.hasSlot(SELECT_SLOT_NAMES.content)
|
|
163
|
-
? this.getSlot(SELECT_SLOT_NAMES.content)
|
|
164
|
-
.map((litElement) => litElement.values[0])
|
|
165
|
-
.filter((element) => element instanceof HOption)
|
|
166
|
-
: Array.from(this.querySelectorAll(SELECT_RELATED_COMPONENTS_NAMES.option));
|
|
167
202
|
this._optionsObserver = new Observer((selectedOptions) => this._updateOptionsView(selectedOptions));
|
|
168
203
|
this._selectController.options$.subscribe(this._optionsObserver);
|
|
169
|
-
this.
|
|
170
|
-
const value = $option.getAttribute('value');
|
|
171
|
-
if (!value)
|
|
172
|
-
throw Error('Select option must hava a value');
|
|
173
|
-
if (acc[value] !== undefined)
|
|
174
|
-
throw Error('Select options must hava a unique values.');
|
|
175
|
-
return {
|
|
176
|
-
...acc,
|
|
177
|
-
[value]: $option
|
|
178
|
-
};
|
|
179
|
-
}, {});
|
|
180
|
-
const options = $options.map(SelectOptionMapper.toModel);
|
|
181
|
-
this._selectController.options$.notify(options);
|
|
182
|
-
if (options.length)
|
|
183
|
-
this._selectController.selectedOptions$.notify(options.filter((option) => option.selected));
|
|
204
|
+
this._updateOptions();
|
|
184
205
|
this._setupEvents();
|
|
185
206
|
}
|
|
186
207
|
attributeChangedCallback(name, _old, value) {
|
|
@@ -220,7 +241,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
220
241
|
const option = this._selectController.getOption(value);
|
|
221
242
|
if (!option)
|
|
222
243
|
return;
|
|
223
|
-
this._selectController.toggle(option);
|
|
244
|
+
this.noDeselect ? this._selectController.select(option) : this._selectController.toggle(option);
|
|
224
245
|
if (!this.multiple)
|
|
225
246
|
this._closeSelect();
|
|
226
247
|
this._dispatchChangeEvent();
|
|
@@ -253,6 +274,11 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
253
274
|
_searchNoResult() {
|
|
254
275
|
return Boolean(!this._selectController.visibleOptionsCount && Object.keys(this._$options).length);
|
|
255
276
|
}
|
|
277
|
+
_renderOption(option) {
|
|
278
|
+
const fragment = document.createDocumentFragment();
|
|
279
|
+
fragment.appendChild(option);
|
|
280
|
+
return fragment;
|
|
281
|
+
}
|
|
256
282
|
render() {
|
|
257
283
|
var _a;
|
|
258
284
|
const options = (_a = this._selectController.options$.getValue()) !== null && _a !== void 0 ? _a : [];
|
|
@@ -288,20 +314,18 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
|
|
|
288
314
|
@selectSearch.search=${this._handleSearch}
|
|
289
315
|
></h-select-search>`
|
|
290
316
|
: nothing}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
`
|
|
304
|
-
: nothing}
|
|
317
|
+
|
|
318
|
+
<h-options
|
|
319
|
+
class="${SELECT_CSS_CLASSES.selectOptions} ${this._searchNoResult()
|
|
320
|
+
? SELECT_CSS_CLASSES.selectOptionsEmpty
|
|
321
|
+
: ''}"
|
|
322
|
+
${ref(this._$optionsList)}
|
|
323
|
+
@selectOptions.clicked=${this._handleOptionClicked}
|
|
324
|
+
@selectOptions.updated=${this._handleOptionUpdated}
|
|
325
|
+
>
|
|
326
|
+
${this._$options ? repeat(Object.values(this._$options), (option) => option.value, (option) => this._renderOption(option)) : nothing}
|
|
327
|
+
</h-options>
|
|
328
|
+
|
|
305
329
|
${this._searchNoResult()
|
|
306
330
|
? html ` <div>
|
|
307
331
|
<p class=${SELECT_CSS_CLASSES.selectNoResult}>
|
|
@@ -375,6 +399,14 @@ __decorate([
|
|
|
375
399
|
property({ type: Boolean }),
|
|
376
400
|
__metadata("design:type", Boolean)
|
|
377
401
|
], HSelect.prototype, "required", void 0);
|
|
402
|
+
__decorate([
|
|
403
|
+
property({ type: Array }),
|
|
404
|
+
__metadata("design:type", Array)
|
|
405
|
+
], HSelect.prototype, "optionsList", void 0);
|
|
406
|
+
__decorate([
|
|
407
|
+
property({ type: Boolean, attribute: 'no-deselect' }),
|
|
408
|
+
__metadata("design:type", Boolean)
|
|
409
|
+
], HSelect.prototype, "noDeselect", void 0);
|
|
378
410
|
__decorate([
|
|
379
411
|
state(),
|
|
380
412
|
__metadata("design:type", String)
|