@sellmate/design-system 0.0.12 → 0.0.13
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/dist/{esm/resolveColor-BYf-ybt2.js → cjs/color-Oz29vj7L.js} +6 -14
- package/dist/cjs/color-Oz29vj7L.js.map +1 -0
- package/dist/cjs/design-system.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/resolveColor-CauSLF0s.js +18 -0
- package/dist/{esm/resolveColor-BYf-ybt2.js.map → cjs/resolveColor-CauSLF0s.js.map} +1 -1
- package/dist/cjs/sd-badge.cjs.entry.js +3 -2
- package/dist/cjs/sd-badge.entry.cjs.js.map +1 -1
- package/dist/cjs/sd-button.sd-tooltip-portal.entry.cjs.js.map +1 -0
- package/dist/cjs/sd-button_2.cjs.entry.js +222 -0
- package/dist/cjs/sd-checkbox.sd-icon.sd-input.sd-portal.sd-select.sd-select-multiple.sd-select-multiple-group.sd-select-option.sd-select-option-group.entry.cjs.js.map +1 -0
- package/dist/cjs/sd-checkbox_9.cjs.entry.js +1650 -0
- package/dist/cjs/{sd-date-box_2.cjs.entry.js → sd-date-box.cjs.entry.js} +1 -119
- package/dist/cjs/sd-date-box.entry.cjs.js.map +1 -0
- package/dist/cjs/sd-date-picker.cjs.entry.js +2 -2
- package/dist/cjs/sd-date-range-picker.cjs.entry.js +2 -2
- package/dist/cjs/sd-guide.cjs.entry.js +109 -0
- package/dist/cjs/sd-guide.entry.cjs.js.map +1 -0
- package/dist/cjs/sd-pagination_2.cjs.entry.js +4 -4
- package/dist/cjs/sd-popover.cjs.entry.js +2 -2
- package/dist/cjs/sd-table.cjs.entry.js +2 -2
- package/dist/cjs/sd-tag.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/event-management.js +20 -0
- package/dist/collection/components/event-management.js.map +1 -0
- package/dist/collection/components/sd-badge/sd-badge.js +1 -1
- package/dist/collection/components/sd-checkbox/sd-checkbox.css +2 -1
- package/dist/collection/components/sd-checkbox/sd-checkbox.js +1 -1
- package/dist/collection/components/sd-date-picker/sd-date-picker.js +2 -2
- package/dist/collection/components/sd-date-range-picker/sd-date-range-picker.js +2 -2
- package/dist/collection/components/sd-guide/sd-guide.js +2 -2
- package/dist/collection/components/sd-icon/sd-icon.js +1 -1
- package/dist/collection/components/sd-input/sd-input.js +2 -2
- package/dist/collection/components/sd-pagination/sd-pagination.js +2 -2
- package/dist/collection/components/sd-popover/sd-popover.js +2 -2
- package/dist/collection/components/sd-portal/sd-portal.js +1 -1
- package/dist/collection/components/sd-select/sd-select-option/sd-select-option.css +6 -0
- package/dist/collection/components/sd-select/sd-select-option/sd-select-option.js +3 -4
- package/dist/collection/components/sd-select/sd-select-option/sd-select-option.js.map +1 -1
- package/dist/collection/components/sd-select/sd-select.js +7 -136
- package/dist/collection/components/sd-select/sd-select.js.map +1 -1
- package/dist/collection/components/sd-select-multiple/sd-select-multiple.css +1504 -0
- package/dist/collection/components/sd-select-multiple/sd-select-multiple.js +585 -0
- package/dist/collection/components/sd-select-multiple/sd-select-multiple.js.map +1 -0
- package/dist/collection/components/sd-select-multiple-group/sd-select-multiple-group.css +1499 -0
- package/dist/collection/components/sd-select-multiple-group/sd-select-multiple-group.js +754 -0
- package/dist/collection/components/sd-select-multiple-group/sd-select-multiple-group.js.map +1 -0
- package/dist/collection/components/sd-select-multiple-group/sd-select-option-group/sd-select-option-group.css +1412 -0
- package/dist/collection/components/sd-select-multiple-group/sd-select-option-group/sd-select-option-group.js +265 -0
- package/dist/collection/components/sd-select-multiple-group/sd-select-option-group/sd-select-option-group.js.map +1 -0
- package/dist/collection/components/sd-table/sd-table.js +2 -2
- package/dist/collection/components/sd-tag/sd-tag.js +1 -1
- package/dist/collection/components/sd-tooltip/sd-tooltip.js +2 -2
- package/dist/collection/components/sd-tooltip-portal/sd-tooltip-portal.js +1 -1
- package/dist/components/{p-BVMP8_7g.js → p-BBm_kUA7.js} +5 -5
- package/dist/components/{p-BVMP8_7g.js.map → p-BBm_kUA7.js.map} +1 -1
- package/dist/components/{p-D7VWdAch.js → p-BqCRj-SM.js} +3 -3
- package/dist/components/{p-D7VWdAch.js.map → p-BqCRj-SM.js.map} +1 -1
- package/dist/components/p-Cf4fh47I.js +106 -0
- package/dist/components/p-Cf4fh47I.js.map +1 -0
- package/dist/components/{p-hwVfUtSx.js → p-CuDrOaaO.js} +5 -5
- package/dist/components/p-CuDrOaaO.js.map +1 -0
- package/dist/components/{p-CiTGsdkP.js → p-Cw2pw4LC.js} +7 -7
- package/dist/components/{p-CiTGsdkP.js.map → p-Cw2pw4LC.js.map} +1 -1
- package/dist/components/{p-BbUf81Wx.js → p-D0hPGqjM.js} +5 -5
- package/dist/components/{p-BbUf81Wx.js.map → p-D0hPGqjM.js.map} +1 -1
- package/dist/components/{p-exVR_ekC.js → p-D267VRcj.js} +3 -3
- package/dist/components/{p-exVR_ekC.js.map → p-D267VRcj.js.map} +1 -1
- package/dist/components/{p-CI-1-u3u.js → p-DVFPBdfj.js} +3 -3
- package/dist/components/{p-CI-1-u3u.js.map → p-DVFPBdfj.js.map} +1 -1
- package/dist/components/{p-CwnpMbLt.js → p-DfkKMnWF.js} +9 -10
- package/dist/components/p-DfkKMnWF.js.map +1 -0
- package/dist/components/p-sQ8mybM7.js +115 -0
- package/dist/components/p-sQ8mybM7.js.map +1 -0
- package/dist/components/{p-BO6LLSyN.js → p-tyC8W4sw.js} +3 -3
- package/dist/components/{p-BO6LLSyN.js.map → p-tyC8W4sw.js.map} +1 -1
- package/dist/components/sd-badge.js +1 -1
- package/dist/components/sd-button.js +1 -1
- package/dist/components/sd-checkbox.js +1 -1
- package/dist/components/sd-date-picker.js +5 -5
- package/dist/components/sd-date-range-picker.js +5 -5
- package/dist/components/sd-guide.js +5 -5
- package/dist/components/sd-icon.js +1 -1
- package/dist/components/sd-input.js +1 -1
- package/dist/components/sd-pagination.js +1 -1
- package/dist/components/sd-popover.js +5 -5
- package/dist/components/sd-portal.js +1 -1
- package/dist/components/sd-select-multiple-group.d.ts +11 -0
- package/dist/components/sd-select-multiple-group.js +389 -0
- package/dist/components/sd-select-multiple-group.js.map +1 -0
- package/dist/components/sd-select-multiple.d.ts +11 -0
- package/dist/components/sd-select-multiple.js +335 -0
- package/dist/components/sd-select-multiple.js.map +1 -0
- package/dist/components/sd-select-option-group.d.ts +11 -0
- package/dist/components/sd-select-option-group.js +9 -0
- package/dist/components/sd-select-option-group.js.map +1 -0
- package/dist/components/sd-select-option.js +1 -1
- package/dist/components/sd-select.js +14 -136
- package/dist/components/sd-select.js.map +1 -1
- package/dist/components/sd-table.js +8 -8
- package/dist/components/sd-tag.js +1 -1
- package/dist/components/sd-tooltip-portal.js +1 -1
- package/dist/components/sd-tooltip.js +1 -1
- package/dist/design-system/design-system.esm.js +1 -1
- package/dist/design-system/{p-4cd267c5.entry.js → p-02d30a1b.entry.js} +2 -2
- package/dist/design-system/p-0529b7d6.entry.js +2 -0
- package/dist/design-system/p-0529b7d6.entry.js.map +1 -0
- package/dist/design-system/{p-fe6d6d27.entry.js → p-131f639a.entry.js} +2 -2
- package/dist/design-system/p-3fe6dda9.entry.js +2 -0
- package/dist/design-system/p-3fe6dda9.entry.js.map +1 -0
- package/dist/design-system/p-52454cc4.entry.js +2 -0
- package/dist/design-system/p-52454cc4.entry.js.map +1 -0
- package/dist/design-system/p-70a394fe.entry.js +2 -0
- package/dist/design-system/p-70a394fe.entry.js.map +1 -0
- package/dist/design-system/p-7ae03d45.entry.js +2 -0
- package/dist/design-system/p-7ae03d45.entry.js.map +1 -0
- package/dist/design-system/p-BoLmB6pG.js +2 -0
- package/dist/design-system/{p-BYf-ybt2.js.map → p-BoLmB6pG.js.map} +1 -1
- package/dist/design-system/{p-BYf-ybt2.js → p-CgyTlXBV.js} +2 -2
- package/dist/design-system/p-CgyTlXBV.js.map +1 -0
- package/dist/design-system/{p-5af93f6e.entry.js → p-a7ef9b22.entry.js} +2 -2
- package/dist/design-system/{p-7dcff5f4.entry.js → p-ab46652a.entry.js} +2 -2
- package/dist/design-system/{p-c89d383a.entry.js → p-b5abb919.entry.js} +2 -2
- package/dist/design-system/{p-585f1e0c.entry.js → p-cdaa51d7.entry.js} +2 -2
- package/dist/design-system/sd-badge.entry.esm.js.map +1 -1
- package/dist/design-system/sd-button.sd-tooltip-portal.entry.esm.js.map +1 -0
- package/dist/design-system/sd-checkbox.sd-icon.sd-input.sd-portal.sd-select.sd-select-multiple.sd-select-multiple-group.sd-select-option.sd-select-option-group.entry.esm.js.map +1 -0
- package/dist/design-system/sd-date-box.entry.esm.js.map +1 -0
- package/dist/design-system/sd-guide.entry.esm.js.map +1 -0
- package/dist/{cjs/resolveColor-DxvExwgo.js → esm/color-CgyTlXBV.js} +4 -17
- package/dist/esm/color-CgyTlXBV.js.map +1 -0
- package/dist/esm/design-system.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/resolveColor-CswQ9y2Q.js +16 -0
- package/dist/{cjs/resolveColor-DxvExwgo.js.map → esm/resolveColor-CswQ9y2Q.js.map} +1 -1
- package/dist/esm/sd-badge.entry.js +3 -2
- package/dist/esm/sd-badge.entry.js.map +1 -1
- package/dist/esm/sd-button.sd-tooltip-portal.entry.js.map +1 -0
- package/dist/esm/sd-button_2.entry.js +219 -0
- package/dist/esm/sd-checkbox.sd-icon.sd-input.sd-portal.sd-select.sd-select-multiple.sd-select-multiple-group.sd-select-option.sd-select-option-group.entry.js.map +1 -0
- package/dist/esm/sd-checkbox_9.entry.js +1640 -0
- package/dist/esm/{sd-date-box_2.entry.js → sd-date-box.entry.js} +3 -120
- package/dist/esm/sd-date-box.entry.js.map +1 -0
- package/dist/esm/sd-date-picker.entry.js +2 -2
- package/dist/esm/sd-date-range-picker.entry.js +2 -2
- package/dist/esm/sd-guide.entry.js +107 -0
- package/dist/esm/sd-guide.entry.js.map +1 -0
- package/dist/esm/sd-pagination_2.entry.js +4 -4
- package/dist/esm/sd-popover.entry.js +2 -2
- package/dist/esm/sd-table.entry.js +2 -2
- package/dist/esm/sd-tag.entry.js +1 -1
- package/dist/types/components/event-management.d.ts +6 -0
- package/dist/types/components/sd-select/sd-select.d.ts +0 -6
- package/dist/types/components/sd-select-multiple/sd-select-multiple.d.ts +54 -0
- package/dist/types/components/sd-select-multiple-group/sd-select-multiple-group.d.ts +75 -0
- package/dist/types/components/sd-select-multiple-group/sd-select-option-group/sd-select-option-group.d.ts +24 -0
- package/dist/types/components.d.ts +336 -12
- package/hydrate/index.js +759 -72
- package/hydrate/index.mjs +759 -72
- package/package.json +2 -2
- package/dist/cjs/sd-button.sd-guide.sd-icon.sd-portal.entry.cjs.js.map +0 -1
- package/dist/cjs/sd-button_4.cjs.entry.js +0 -587
- package/dist/cjs/sd-checkbox.cjs.entry.js +0 -81
- package/dist/cjs/sd-checkbox.entry.cjs.js.map +0 -1
- package/dist/cjs/sd-date-box.sd-input.entry.cjs.js.map +0 -1
- package/dist/cjs/sd-select-option.cjs.entry.js +0 -55
- package/dist/cjs/sd-select-option.entry.cjs.js.map +0 -1
- package/dist/cjs/sd-select.cjs.entry.js +0 -371
- package/dist/cjs/sd-select.entry.cjs.js.map +0 -1
- package/dist/cjs/sd-tooltip-portal.cjs.entry.js +0 -158
- package/dist/cjs/sd-tooltip-portal.entry.cjs.js.map +0 -1
- package/dist/components/p-CwnpMbLt.js.map +0 -1
- package/dist/components/p-hwVfUtSx.js.map +0 -1
- package/dist/design-system/p-3824f9a6.entry.js +0 -2
- package/dist/design-system/p-3824f9a6.entry.js.map +0 -1
- package/dist/design-system/p-71ac64b0.entry.js +0 -2
- package/dist/design-system/p-71ac64b0.entry.js.map +0 -1
- package/dist/design-system/p-9f6aa159.entry.js +0 -2
- package/dist/design-system/p-9f6aa159.entry.js.map +0 -1
- package/dist/design-system/p-bfd17f46.entry.js +0 -2
- package/dist/design-system/p-bfd17f46.entry.js.map +0 -1
- package/dist/design-system/p-c7b6d94d.entry.js +0 -2
- package/dist/design-system/p-c7b6d94d.entry.js.map +0 -1
- package/dist/design-system/p-ca8e64cf.entry.js +0 -2
- package/dist/design-system/p-ca8e64cf.entry.js.map +0 -1
- package/dist/design-system/p-d4395043.entry.js +0 -2
- package/dist/design-system/p-d4395043.entry.js.map +0 -1
- package/dist/design-system/sd-button.sd-guide.sd-icon.sd-portal.entry.esm.js.map +0 -1
- package/dist/design-system/sd-checkbox.entry.esm.js.map +0 -1
- package/dist/design-system/sd-date-box.sd-input.entry.esm.js.map +0 -1
- package/dist/design-system/sd-select-option.entry.esm.js.map +0 -1
- package/dist/design-system/sd-select.entry.esm.js.map +0 -1
- package/dist/design-system/sd-tooltip-portal.entry.esm.js.map +0 -1
- package/dist/esm/sd-button.sd-guide.sd-icon.sd-portal.entry.js.map +0 -1
- package/dist/esm/sd-button_4.entry.js +0 -582
- package/dist/esm/sd-checkbox.entry.js +0 -79
- package/dist/esm/sd-checkbox.entry.js.map +0 -1
- package/dist/esm/sd-date-box.sd-input.entry.js.map +0 -1
- package/dist/esm/sd-select-option.entry.js +0 -53
- package/dist/esm/sd-select-option.entry.js.map +0 -1
- package/dist/esm/sd-select.entry.js +0 -369
- package/dist/esm/sd-select.entry.js.map +0 -1
- package/dist/esm/sd-tooltip-portal.entry.js +0 -156
- package/dist/esm/sd-tooltip-portal.entry.js.map +0 -1
- /package/dist/design-system/{p-4cd267c5.entry.js.map → p-02d30a1b.entry.js.map} +0 -0
- /package/dist/design-system/{p-fe6d6d27.entry.js.map → p-131f639a.entry.js.map} +0 -0
- /package/dist/design-system/{p-5af93f6e.entry.js.map → p-a7ef9b22.entry.js.map} +0 -0
- /package/dist/design-system/{p-7dcff5f4.entry.js.map → p-ab46652a.entry.js.map} +0 -0
- /package/dist/design-system/{p-c89d383a.entry.js.map → p-b5abb919.entry.js.map} +0 -0
- /package/dist/design-system/{p-585f1e0c.entry.js.map → p-cdaa51d7.entry.js.map} +0 -0
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
import { Host, h, } from "@stencil/core";
|
|
2
|
+
import { SelectKeyboardNavigation } from "../../utils/select-keyboard-navigation";
|
|
3
|
+
import { BaseDropdownEvent } from "../../utils/base-dropdown-event";
|
|
4
|
+
export class SdSelectMultiple extends BaseDropdownEvent {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
}
|
|
8
|
+
el;
|
|
9
|
+
// props
|
|
10
|
+
value = null;
|
|
11
|
+
label = '';
|
|
12
|
+
options = [];
|
|
13
|
+
placeholder = '선택';
|
|
14
|
+
optionPlaceholder = '옵션이 없습니다.';
|
|
15
|
+
width = '200px';
|
|
16
|
+
dropdownHeight = '260px';
|
|
17
|
+
disabled = false;
|
|
18
|
+
clearable = false;
|
|
19
|
+
searchable = false;
|
|
20
|
+
useCheckbox = false;
|
|
21
|
+
// props - custom slots
|
|
22
|
+
optionRenderer;
|
|
23
|
+
// states
|
|
24
|
+
filteredOptions = this.options;
|
|
25
|
+
isOpen = false;
|
|
26
|
+
searchText = null;
|
|
27
|
+
itemIndex = -1;
|
|
28
|
+
isScrolled = false;
|
|
29
|
+
// events
|
|
30
|
+
sdChange;
|
|
31
|
+
dropDownShow;
|
|
32
|
+
selectRef;
|
|
33
|
+
searchRef;
|
|
34
|
+
optionRef;
|
|
35
|
+
dropdownRef;
|
|
36
|
+
valueChanged() {
|
|
37
|
+
this.sdChange?.emit(this.value);
|
|
38
|
+
}
|
|
39
|
+
optionsChanged() {
|
|
40
|
+
this.filteredOptions = this.options;
|
|
41
|
+
this.filterOptions();
|
|
42
|
+
}
|
|
43
|
+
searchTextChanged() {
|
|
44
|
+
this.filterOptions();
|
|
45
|
+
}
|
|
46
|
+
async itemIndexChanged(newIndex, oldIndex) {
|
|
47
|
+
if (this.searchable) {
|
|
48
|
+
const searchInput = await this.getNativeInputElement();
|
|
49
|
+
if (this.itemIndex === -1) {
|
|
50
|
+
searchInput?.focus();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
else if (searchInput?.matches(':focus')) {
|
|
54
|
+
searchInput?.blur();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const optionElements = Array.from(this.dropdownRef?.querySelectorAll('.sd-select-multiple__dropdown sd-select-option') || []);
|
|
58
|
+
const currentItem = optionElements?.[this.itemIndex];
|
|
59
|
+
if (!currentItem || !this.isOpen)
|
|
60
|
+
return;
|
|
61
|
+
this.optionRef = currentItem;
|
|
62
|
+
const isOptionDisabled = await this.optionRef.isDisabled();
|
|
63
|
+
if (isOptionDisabled) {
|
|
64
|
+
newIndex > oldIndex ? this.itemIndex++ : this.itemIndex--;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.scrollToOption(currentItem);
|
|
68
|
+
}
|
|
69
|
+
async isOpenChanged() {
|
|
70
|
+
// Base class의 이벤트 관리 호출 - 다른 select와의 이벤트 충돌 방지
|
|
71
|
+
this.onDropdownToggle(this.isOpen);
|
|
72
|
+
const selectedOption = this.getSelectedOption();
|
|
73
|
+
if (!selectedOption) {
|
|
74
|
+
this.itemIndex = -1;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.itemIndex = this.options.indexOf(selectedOption[0]);
|
|
78
|
+
}
|
|
79
|
+
this.dropDownShow?.emit({ isOpen: this.isOpen });
|
|
80
|
+
if (this.isOpen === false)
|
|
81
|
+
return;
|
|
82
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
83
|
+
const optionElements = Array.from(this.dropdownRef?.querySelectorAll('.sd-select-multiple__dropdown sd-select-item') || []);
|
|
84
|
+
const currentItem = optionElements?.[this.itemIndex];
|
|
85
|
+
// 드롭다운이 열릴 때 검색 입력에 포커스
|
|
86
|
+
if (this.searchable) {
|
|
87
|
+
const searchInput = await this.getNativeInputElement();
|
|
88
|
+
searchInput?.focus();
|
|
89
|
+
}
|
|
90
|
+
if (!currentItem)
|
|
91
|
+
return;
|
|
92
|
+
await new Promise(resolve => setTimeout(resolve, 10)); // 추가 딜레이
|
|
93
|
+
this.scrollToOption(currentItem);
|
|
94
|
+
}
|
|
95
|
+
connectedCallback() {
|
|
96
|
+
// props가 모두 설정된 후에 실행되므로 올바른 options 값을 가져올 수 있음
|
|
97
|
+
this.filteredOptions = this.options;
|
|
98
|
+
this.initializeEvent(); // global dropdown Manager에 등록 + 이벤트 핸들러 초기화
|
|
99
|
+
}
|
|
100
|
+
disconnectedCallback() {
|
|
101
|
+
this.cleanupEvent(); // global dropdown Manager에서 제거 + 이벤트 정리
|
|
102
|
+
}
|
|
103
|
+
handleDocumentClick(event) {
|
|
104
|
+
if (!this.selectRef?.contains(event.target)) {
|
|
105
|
+
this.isOpen = false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
handleDocumentKeydown(keyboardEvent) {
|
|
109
|
+
keyboardEvent.stopPropagation();
|
|
110
|
+
const targetKey = ['ArrowDown', 'ArrowUp', 'Enter', 'Escape'];
|
|
111
|
+
if (!targetKey.includes(keyboardEvent.key))
|
|
112
|
+
return;
|
|
113
|
+
keyboardEvent.preventDefault();
|
|
114
|
+
switch (keyboardEvent.key) {
|
|
115
|
+
case 'ArrowDown':
|
|
116
|
+
case 'ArrowUp':
|
|
117
|
+
const keyboardNavigation = new SelectKeyboardNavigation(this.searchable, this.filteredOptions);
|
|
118
|
+
const nextIndex = keyboardNavigation.getNextIndex(this.itemIndex, keyboardEvent.key);
|
|
119
|
+
this.itemIndex = nextIndex;
|
|
120
|
+
break;
|
|
121
|
+
case 'Enter':
|
|
122
|
+
const selectedOption = this.filteredOptions[this.itemIndex];
|
|
123
|
+
if (selectedOption && !selectedOption.disabled) {
|
|
124
|
+
this.handleOptionSelection(selectedOption);
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
case 'Escape':
|
|
128
|
+
this.isOpen = false;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// event handlers
|
|
133
|
+
handleTriggerClick = (event) => {
|
|
134
|
+
event.stopPropagation();
|
|
135
|
+
if (!this.disabled) {
|
|
136
|
+
this.isOpen = !this.isOpen;
|
|
137
|
+
this.dropDownShow?.emit({ isOpen: this.isOpen });
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
handleOptionClick = (detail) => {
|
|
141
|
+
const { option, event } = detail;
|
|
142
|
+
event.stopPropagation();
|
|
143
|
+
this.handleOptionSelection(option);
|
|
144
|
+
};
|
|
145
|
+
filterOptions() {
|
|
146
|
+
if (!this.searchText || this.searchText.trim() === '') {
|
|
147
|
+
// 검색어가 없으면 전체 옵션 표시
|
|
148
|
+
this.filteredOptions = this.options;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
// 검색어가 있으면 필터링
|
|
152
|
+
this.filteredOptions = this.options.filter(option => option.label.toLowerCase().includes(this.searchText.toLowerCase()));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
getSelectedOption() {
|
|
156
|
+
return this.options.filter(option => this.value?.includes(option));
|
|
157
|
+
}
|
|
158
|
+
handleDropdownScroll = (event) => {
|
|
159
|
+
const target = event.target;
|
|
160
|
+
const scrollTop = target.scrollTop;
|
|
161
|
+
// 스크롤이 조금이라도 되면 그림자 표시
|
|
162
|
+
this.isScrolled = scrollTop > 0;
|
|
163
|
+
};
|
|
164
|
+
async getNativeInputElement() {
|
|
165
|
+
if (this.searchRef) {
|
|
166
|
+
return this.searchRef.getNativeElement();
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
handleOptionSelection = (option) => {
|
|
171
|
+
if (!option || option.disabled)
|
|
172
|
+
return;
|
|
173
|
+
const isAlreadySelected = this.value?.some(opt => opt.value === option.value);
|
|
174
|
+
if (isAlreadySelected) {
|
|
175
|
+
// 이미 선택된 옵션인 경우, 선택 해제
|
|
176
|
+
this.value = this.value?.filter(opt => opt.value !== option.value) || null;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
// 새로운 옵션 선택
|
|
180
|
+
this.value = [...(this.value || []), option];
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
closeDropdown() {
|
|
184
|
+
this.isOpen = false;
|
|
185
|
+
}
|
|
186
|
+
scrollToOption(optionElement) {
|
|
187
|
+
if (!this.dropdownRef || !optionElement)
|
|
188
|
+
return;
|
|
189
|
+
const dropdown = this.dropdownRef;
|
|
190
|
+
const optionTop = optionElement.offsetTop;
|
|
191
|
+
const optionHeight = optionElement.offsetHeight;
|
|
192
|
+
const dropdownScrollTop = dropdown.scrollTop;
|
|
193
|
+
const dropdownHeight = dropdown.clientHeight;
|
|
194
|
+
const searchContainer = dropdown.querySelector('.sd-select__search-container');
|
|
195
|
+
const searchOffset = searchContainer ? searchContainer.offsetHeight : 0;
|
|
196
|
+
const visibleTop = dropdownScrollTop + searchOffset;
|
|
197
|
+
const visibleBottom = dropdownScrollTop + dropdownHeight;
|
|
198
|
+
if (optionTop < visibleTop) {
|
|
199
|
+
dropdown.scrollTop = optionTop - searchOffset;
|
|
200
|
+
}
|
|
201
|
+
else if (optionTop + optionHeight > visibleBottom) {
|
|
202
|
+
dropdown.scrollTop = optionTop + optionHeight - dropdownHeight + searchOffset;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// render method
|
|
206
|
+
render() {
|
|
207
|
+
const style = {
|
|
208
|
+
'--select-width': this.width || '200px',
|
|
209
|
+
'--select-dropdown-height': this.dropdownHeight || '260px',
|
|
210
|
+
};
|
|
211
|
+
return (h(Host, { key: '7f809c5d682b5f03e624151a23056e93dd420704', style: style }, h("div", { key: 'e681c6817d2245a9b3d9f168a972beb6b9c648aa', class: {
|
|
212
|
+
'sd-select-multiple': true,
|
|
213
|
+
'sd-select-multiple--open': this.isOpen,
|
|
214
|
+
'sd-select-multiple--disabled': this.disabled,
|
|
215
|
+
}, ref: el => (this.selectRef = el) }, this.renderLabel(this.label), h("div", { key: 'f3b36403172d090098f618b7aa734e0d2aacfe71', class: "sd-select-multiple__container" }, this.renderTrigger(), this.renderDropdown()))));
|
|
216
|
+
}
|
|
217
|
+
renderLabel(label) {
|
|
218
|
+
if (!label)
|
|
219
|
+
return null;
|
|
220
|
+
return h("label", { class: "sd-select-multiple__label" }, label);
|
|
221
|
+
}
|
|
222
|
+
renderTrigger() {
|
|
223
|
+
const selectedOption = this.getSelectedOption();
|
|
224
|
+
return (h("div", { class: "sd-select-multiple__trigger", tabindex: this.disabled ? -1 : 0, onClick: this.handleTriggerClick }, h("span", { class: "sd-select-multiple__value" }, !selectedOption
|
|
225
|
+
? '선택'
|
|
226
|
+
: selectedOption.length
|
|
227
|
+
? selectedOption.map(option => option.label).join(', ')
|
|
228
|
+
: this.placeholder), this.clearable && selectedOption?.length > 0 && !this.disabled && (h("sd-icon", { key: "close-icon", name: "close", size: 10, color: "#888", class: "sd-select-multiple__clear", onClick: event => {
|
|
229
|
+
event.stopPropagation();
|
|
230
|
+
this.value = null;
|
|
231
|
+
} })), h("sd-icon", { key: "arrow-icon", name: "arrowDown", color: "#888", class: { 'sd-select-multiple__arrow': true, 'sd-select-multiple__arrow--open': this.isOpen } })));
|
|
232
|
+
}
|
|
233
|
+
renderDropdown() {
|
|
234
|
+
if (this.isOpen === false)
|
|
235
|
+
return null;
|
|
236
|
+
return (h("sd-portal", { open: this.isOpen, parentRef: this.selectRef, onSdClose: this.closeDropdown }, h("div", { class: "sd-select-multiple__dropdown", onScroll: this.handleDropdownScroll, ref: el => (this.dropdownRef = el) }, this.searchable && (h("div", { class: {
|
|
237
|
+
'sd-select-multiple__search-container': true,
|
|
238
|
+
'sd-select-multiple__search-container--scrolled': this.isScrolled,
|
|
239
|
+
}, onClick: event => event.stopPropagation() }, h("sd-input", { ref: el => (this.searchRef = el), value: this.searchText, placeholder: "\uAC80\uC0C9", clearable: true, inputStyle: { 'padding-left': '8px' }, autofocus: true, onSdInput: event => {
|
|
240
|
+
this.searchText = String(event?.detail);
|
|
241
|
+
}, onSdFocus: () => {
|
|
242
|
+
this.itemIndex = -1;
|
|
243
|
+
} }, h("sd-icon", { name: "search", size: 16, color: "#737373", style: { marginRight: '4px' }, slot: "prefix" })))), this.filteredOptions.length > 0 ? (this.filteredOptions.map((option, index) => (h("slot", { name: `option-${option.value}` }, h("sd-select-option", { option: option, index: index, isSelected: this.value?.some(selected => selected.value === option.value), isFocused: index === this.itemIndex, onOptionClick: ({ detail }) => this.handleOptionClick(detail), useCheckbox: this.useCheckbox }))))) : (h("slot", { name: "option-placeholder" }, h("div", { class: 'sd-select-multiple__option-placeholder' }, this.optionPlaceholder))))));
|
|
244
|
+
}
|
|
245
|
+
static get is() { return "sd-select-multiple"; }
|
|
246
|
+
static get originalStyleUrls() {
|
|
247
|
+
return {
|
|
248
|
+
"$": ["sd-select-multiple.scss"]
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
static get styleUrls() {
|
|
252
|
+
return {
|
|
253
|
+
"$": ["sd-select-multiple.css"]
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
static get properties() {
|
|
257
|
+
return {
|
|
258
|
+
"value": {
|
|
259
|
+
"type": "unknown",
|
|
260
|
+
"mutable": true,
|
|
261
|
+
"complexType": {
|
|
262
|
+
"original": "SelectOption[] | null",
|
|
263
|
+
"resolved": "SelectOption[] | null",
|
|
264
|
+
"references": {
|
|
265
|
+
"SelectOption": {
|
|
266
|
+
"location": "import",
|
|
267
|
+
"path": "../../types/select",
|
|
268
|
+
"id": "src/types/select.ts::SelectOption"
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
"required": false,
|
|
273
|
+
"optional": false,
|
|
274
|
+
"docs": {
|
|
275
|
+
"tags": [],
|
|
276
|
+
"text": ""
|
|
277
|
+
},
|
|
278
|
+
"getter": false,
|
|
279
|
+
"setter": false,
|
|
280
|
+
"defaultValue": "null"
|
|
281
|
+
},
|
|
282
|
+
"label": {
|
|
283
|
+
"type": "string",
|
|
284
|
+
"mutable": false,
|
|
285
|
+
"complexType": {
|
|
286
|
+
"original": "string",
|
|
287
|
+
"resolved": "string",
|
|
288
|
+
"references": {}
|
|
289
|
+
},
|
|
290
|
+
"required": false,
|
|
291
|
+
"optional": false,
|
|
292
|
+
"docs": {
|
|
293
|
+
"tags": [],
|
|
294
|
+
"text": ""
|
|
295
|
+
},
|
|
296
|
+
"getter": false,
|
|
297
|
+
"setter": false,
|
|
298
|
+
"reflect": false,
|
|
299
|
+
"attribute": "label",
|
|
300
|
+
"defaultValue": "''"
|
|
301
|
+
},
|
|
302
|
+
"options": {
|
|
303
|
+
"type": "unknown",
|
|
304
|
+
"mutable": true,
|
|
305
|
+
"complexType": {
|
|
306
|
+
"original": "SelectOption[]",
|
|
307
|
+
"resolved": "SelectOption[]",
|
|
308
|
+
"references": {
|
|
309
|
+
"SelectOption": {
|
|
310
|
+
"location": "import",
|
|
311
|
+
"path": "../../types/select",
|
|
312
|
+
"id": "src/types/select.ts::SelectOption"
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
"required": false,
|
|
317
|
+
"optional": false,
|
|
318
|
+
"docs": {
|
|
319
|
+
"tags": [],
|
|
320
|
+
"text": ""
|
|
321
|
+
},
|
|
322
|
+
"getter": false,
|
|
323
|
+
"setter": false,
|
|
324
|
+
"defaultValue": "[]"
|
|
325
|
+
},
|
|
326
|
+
"placeholder": {
|
|
327
|
+
"type": "string",
|
|
328
|
+
"mutable": false,
|
|
329
|
+
"complexType": {
|
|
330
|
+
"original": "string",
|
|
331
|
+
"resolved": "string",
|
|
332
|
+
"references": {}
|
|
333
|
+
},
|
|
334
|
+
"required": false,
|
|
335
|
+
"optional": false,
|
|
336
|
+
"docs": {
|
|
337
|
+
"tags": [],
|
|
338
|
+
"text": ""
|
|
339
|
+
},
|
|
340
|
+
"getter": false,
|
|
341
|
+
"setter": false,
|
|
342
|
+
"reflect": false,
|
|
343
|
+
"attribute": "placeholder",
|
|
344
|
+
"defaultValue": "'\uC120\uD0DD'"
|
|
345
|
+
},
|
|
346
|
+
"optionPlaceholder": {
|
|
347
|
+
"type": "string",
|
|
348
|
+
"mutable": false,
|
|
349
|
+
"complexType": {
|
|
350
|
+
"original": "string",
|
|
351
|
+
"resolved": "string",
|
|
352
|
+
"references": {}
|
|
353
|
+
},
|
|
354
|
+
"required": false,
|
|
355
|
+
"optional": false,
|
|
356
|
+
"docs": {
|
|
357
|
+
"tags": [],
|
|
358
|
+
"text": ""
|
|
359
|
+
},
|
|
360
|
+
"getter": false,
|
|
361
|
+
"setter": false,
|
|
362
|
+
"reflect": false,
|
|
363
|
+
"attribute": "option-placeholder",
|
|
364
|
+
"defaultValue": "'\uC635\uC158\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.'"
|
|
365
|
+
},
|
|
366
|
+
"width": {
|
|
367
|
+
"type": "string",
|
|
368
|
+
"mutable": false,
|
|
369
|
+
"complexType": {
|
|
370
|
+
"original": "string",
|
|
371
|
+
"resolved": "string",
|
|
372
|
+
"references": {}
|
|
373
|
+
},
|
|
374
|
+
"required": false,
|
|
375
|
+
"optional": false,
|
|
376
|
+
"docs": {
|
|
377
|
+
"tags": [],
|
|
378
|
+
"text": ""
|
|
379
|
+
},
|
|
380
|
+
"getter": false,
|
|
381
|
+
"setter": false,
|
|
382
|
+
"reflect": false,
|
|
383
|
+
"attribute": "width",
|
|
384
|
+
"defaultValue": "'200px'"
|
|
385
|
+
},
|
|
386
|
+
"dropdownHeight": {
|
|
387
|
+
"type": "string",
|
|
388
|
+
"mutable": false,
|
|
389
|
+
"complexType": {
|
|
390
|
+
"original": "string",
|
|
391
|
+
"resolved": "string",
|
|
392
|
+
"references": {}
|
|
393
|
+
},
|
|
394
|
+
"required": false,
|
|
395
|
+
"optional": false,
|
|
396
|
+
"docs": {
|
|
397
|
+
"tags": [],
|
|
398
|
+
"text": ""
|
|
399
|
+
},
|
|
400
|
+
"getter": false,
|
|
401
|
+
"setter": false,
|
|
402
|
+
"reflect": false,
|
|
403
|
+
"attribute": "dropdown-height",
|
|
404
|
+
"defaultValue": "'260px'"
|
|
405
|
+
},
|
|
406
|
+
"disabled": {
|
|
407
|
+
"type": "boolean",
|
|
408
|
+
"mutable": false,
|
|
409
|
+
"complexType": {
|
|
410
|
+
"original": "boolean",
|
|
411
|
+
"resolved": "boolean",
|
|
412
|
+
"references": {}
|
|
413
|
+
},
|
|
414
|
+
"required": false,
|
|
415
|
+
"optional": false,
|
|
416
|
+
"docs": {
|
|
417
|
+
"tags": [],
|
|
418
|
+
"text": ""
|
|
419
|
+
},
|
|
420
|
+
"getter": false,
|
|
421
|
+
"setter": false,
|
|
422
|
+
"reflect": false,
|
|
423
|
+
"attribute": "disabled",
|
|
424
|
+
"defaultValue": "false"
|
|
425
|
+
},
|
|
426
|
+
"clearable": {
|
|
427
|
+
"type": "boolean",
|
|
428
|
+
"mutable": false,
|
|
429
|
+
"complexType": {
|
|
430
|
+
"original": "boolean",
|
|
431
|
+
"resolved": "boolean",
|
|
432
|
+
"references": {}
|
|
433
|
+
},
|
|
434
|
+
"required": false,
|
|
435
|
+
"optional": false,
|
|
436
|
+
"docs": {
|
|
437
|
+
"tags": [],
|
|
438
|
+
"text": ""
|
|
439
|
+
},
|
|
440
|
+
"getter": false,
|
|
441
|
+
"setter": false,
|
|
442
|
+
"reflect": false,
|
|
443
|
+
"attribute": "clearable",
|
|
444
|
+
"defaultValue": "false"
|
|
445
|
+
},
|
|
446
|
+
"searchable": {
|
|
447
|
+
"type": "boolean",
|
|
448
|
+
"mutable": false,
|
|
449
|
+
"complexType": {
|
|
450
|
+
"original": "boolean",
|
|
451
|
+
"resolved": "boolean",
|
|
452
|
+
"references": {}
|
|
453
|
+
},
|
|
454
|
+
"required": false,
|
|
455
|
+
"optional": false,
|
|
456
|
+
"docs": {
|
|
457
|
+
"tags": [],
|
|
458
|
+
"text": ""
|
|
459
|
+
},
|
|
460
|
+
"getter": false,
|
|
461
|
+
"setter": false,
|
|
462
|
+
"reflect": false,
|
|
463
|
+
"attribute": "searchable",
|
|
464
|
+
"defaultValue": "false"
|
|
465
|
+
},
|
|
466
|
+
"useCheckbox": {
|
|
467
|
+
"type": "boolean",
|
|
468
|
+
"mutable": false,
|
|
469
|
+
"complexType": {
|
|
470
|
+
"original": "boolean",
|
|
471
|
+
"resolved": "boolean",
|
|
472
|
+
"references": {}
|
|
473
|
+
},
|
|
474
|
+
"required": false,
|
|
475
|
+
"optional": false,
|
|
476
|
+
"docs": {
|
|
477
|
+
"tags": [],
|
|
478
|
+
"text": ""
|
|
479
|
+
},
|
|
480
|
+
"getter": false,
|
|
481
|
+
"setter": false,
|
|
482
|
+
"reflect": false,
|
|
483
|
+
"attribute": "use-checkbox",
|
|
484
|
+
"defaultValue": "false"
|
|
485
|
+
},
|
|
486
|
+
"optionRenderer": {
|
|
487
|
+
"type": "unknown",
|
|
488
|
+
"mutable": false,
|
|
489
|
+
"complexType": {
|
|
490
|
+
"original": "(option: SelectOption, index: number, isSelected: boolean) => any",
|
|
491
|
+
"resolved": "((option: SelectOption, index: number, isSelected: boolean) => any) | undefined",
|
|
492
|
+
"references": {
|
|
493
|
+
"SelectOption": {
|
|
494
|
+
"location": "import",
|
|
495
|
+
"path": "../../types/select",
|
|
496
|
+
"id": "src/types/select.ts::SelectOption"
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
"required": false,
|
|
501
|
+
"optional": true,
|
|
502
|
+
"docs": {
|
|
503
|
+
"tags": [],
|
|
504
|
+
"text": ""
|
|
505
|
+
},
|
|
506
|
+
"getter": false,
|
|
507
|
+
"setter": false
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
static get states() {
|
|
512
|
+
return {
|
|
513
|
+
"filteredOptions": {},
|
|
514
|
+
"isOpen": {},
|
|
515
|
+
"searchText": {},
|
|
516
|
+
"itemIndex": {},
|
|
517
|
+
"isScrolled": {}
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
static get events() {
|
|
521
|
+
return [{
|
|
522
|
+
"method": "sdChange",
|
|
523
|
+
"name": "sdChange",
|
|
524
|
+
"bubbles": true,
|
|
525
|
+
"cancelable": true,
|
|
526
|
+
"composed": true,
|
|
527
|
+
"docs": {
|
|
528
|
+
"tags": [],
|
|
529
|
+
"text": ""
|
|
530
|
+
},
|
|
531
|
+
"complexType": {
|
|
532
|
+
"original": "SelectMultipleEvents['sdChange']",
|
|
533
|
+
"resolved": "SelectOption[] | null",
|
|
534
|
+
"references": {
|
|
535
|
+
"SelectMultipleEvents": {
|
|
536
|
+
"location": "import",
|
|
537
|
+
"path": "../../types/select",
|
|
538
|
+
"id": "src/types/select.ts::SelectMultipleEvents"
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}, {
|
|
543
|
+
"method": "dropDownShow",
|
|
544
|
+
"name": "dropDownShow",
|
|
545
|
+
"bubbles": true,
|
|
546
|
+
"cancelable": true,
|
|
547
|
+
"composed": true,
|
|
548
|
+
"docs": {
|
|
549
|
+
"tags": [],
|
|
550
|
+
"text": ""
|
|
551
|
+
},
|
|
552
|
+
"complexType": {
|
|
553
|
+
"original": "SelectMultipleEvents['dropDownShow']",
|
|
554
|
+
"resolved": "{ isOpen: boolean; }",
|
|
555
|
+
"references": {
|
|
556
|
+
"SelectMultipleEvents": {
|
|
557
|
+
"location": "import",
|
|
558
|
+
"path": "../../types/select",
|
|
559
|
+
"id": "src/types/select.ts::SelectMultipleEvents"
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}];
|
|
564
|
+
}
|
|
565
|
+
static get elementRef() { return "el"; }
|
|
566
|
+
static get watchers() {
|
|
567
|
+
return [{
|
|
568
|
+
"propName": "value",
|
|
569
|
+
"methodName": "valueChanged"
|
|
570
|
+
}, {
|
|
571
|
+
"propName": "options",
|
|
572
|
+
"methodName": "optionsChanged"
|
|
573
|
+
}, {
|
|
574
|
+
"propName": "searchText",
|
|
575
|
+
"methodName": "searchTextChanged"
|
|
576
|
+
}, {
|
|
577
|
+
"propName": "itemIndex",
|
|
578
|
+
"methodName": "itemIndexChanged"
|
|
579
|
+
}, {
|
|
580
|
+
"propName": "isOpen",
|
|
581
|
+
"methodName": "isOpenChanged"
|
|
582
|
+
}];
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
//# sourceMappingURL=sd-select-multiple.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sd-select-multiple.js","sourceRoot":"","sources":["../../../src/components/sd-select-multiple/sd-select-multiple.tsx"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,OAAO,EACP,KAAK,EAEL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,KAAK,EACL,CAAC,GACD,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAMpE,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;;;;IAC3C,EAAE,CAAe;IAE5B,QAAQ;IACiB,KAAK,GAA0B,IAAI,CAAC;IACrD,KAAK,GAAW,EAAE,CAAC;IACF,OAAO,GAAmB,EAAE,CAAC;IAC9C,WAAW,GAAW,IAAI,CAAC;IAC3B,iBAAiB,GAAW,WAAW,CAAC;IACxC,KAAK,GAAW,OAAO,CAAC;IACxB,cAAc,GAAW,OAAO,CAAC;IACjC,QAAQ,GAAY,KAAK,CAAC;IAC1B,SAAS,GAAY,KAAK,CAAC;IAC3B,UAAU,GAAY,KAAK,CAAC;IAC5B,WAAW,GAAY,KAAK,CAAC;IAErC,uBAAuB;IACf,cAAc,CAAqE;IAE3F,SAAS;IACA,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC;IAC/B,MAAM,GAAY,KAAK,CAAC;IACxB,UAAU,GAAkB,IAAI,CAAC;IACjC,SAAS,GAAW,CAAC,CAAC,CAAC;IACvB,UAAU,GAAY,KAAK,CAAC;IAErC,SAAS;IACA,QAAQ,CAAkD;IAC1D,YAAY,CAAsD;IAEnE,SAAS,CAAe;IACxB,SAAS,CAAsB;IAC/B,SAAS,CAA6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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACD","sourcesContent":["import {\r\n Component,\r\n Element,\r\n Event,\r\n EventEmitter,\r\n Host,\r\n Prop,\r\n State,\r\n Watch,\r\n h,\r\n} from '@stencil/core';\r\nimport type { SelectOption, SelectMultipleEvents } from '../../types/select';\r\nimport { SelectKeyboardNavigation } from '../../utils/select-keyboard-navigation';\r\nimport { BaseDropdownEvent } from '../../utils/base-dropdown-event';\r\n\r\n@Component({\r\n tag: 'sd-select-multiple',\r\n styleUrl: 'sd-select-multiple.scss',\r\n})\r\nexport class SdSelectMultiple extends BaseDropdownEvent {\r\n @Element() el!: HTMLElement;\r\n\r\n // props\r\n @Prop({ mutable: true }) value: SelectOption[] | null = null;\r\n @Prop() label: string = '';\r\n @Prop({ mutable: true }) options: SelectOption[] = [];\r\n @Prop() placeholder: string = '선택';\r\n @Prop() optionPlaceholder: string = '옵션이 없습니다.';\r\n @Prop() width: string = '200px';\r\n @Prop() dropdownHeight: string = '260px';\r\n @Prop() disabled: boolean = false;\r\n @Prop() clearable: boolean = false;\r\n @Prop() searchable: boolean = false;\r\n @Prop() useCheckbox: boolean = false;\r\n\r\n // props - custom slots\r\n @Prop() optionRenderer?: (option: SelectOption, index: number, isSelected: boolean) => any;\r\n\r\n // states\r\n @State() filteredOptions = this.options;\r\n @State() isOpen: boolean = false;\r\n @State() searchText: string | null = null;\r\n @State() itemIndex: number = -1;\r\n @State() isScrolled: boolean = false;\r\n\r\n // events\r\n @Event() sdChange?: EventEmitter<SelectMultipleEvents['sdChange']>;\r\n @Event() dropDownShow?: EventEmitter<SelectMultipleEvents['dropDownShow']>;\r\n\r\n private selectRef?: HTMLElement;\r\n private searchRef?: HTMLSdInputElement;\r\n private optionRef?: HTMLSdSelectOptionElement;\r\n private dropdownRef?: HTMLElement;\r\n\r\n @Watch('value')\r\n valueChanged() {\r\n this.sdChange?.emit(this.value);\r\n }\r\n\r\n @Watch('options')\r\n optionsChanged() {\r\n this.filteredOptions = this.options;\r\n this.filterOptions();\r\n }\r\n\r\n @Watch('searchText')\r\n searchTextChanged() {\r\n this.filterOptions();\r\n }\r\n\r\n @Watch('itemIndex')\r\n async itemIndexChanged(newIndex: number, oldIndex: number) {\r\n if (this.searchable) {\r\n const searchInput = await this.getNativeInputElement();\r\n if (this.itemIndex === -1) {\r\n searchInput?.focus();\r\n return;\r\n } else if (searchInput?.matches(':focus')) {\r\n searchInput?.blur();\r\n }\r\n }\r\n\r\n const optionElements = Array.from(\r\n this.dropdownRef?.querySelectorAll('.sd-select-multiple__dropdown sd-select-option') || [],\r\n );\r\n const currentItem = optionElements?.[this.itemIndex];\r\n\r\n if (!currentItem || !this.isOpen) return;\r\n\r\n this.optionRef = currentItem as HTMLSdSelectOptionElement;\r\n const isOptionDisabled = await this.optionRef.isDisabled();\r\n\r\n if (isOptionDisabled) {\r\n newIndex > oldIndex ? this.itemIndex++ : this.itemIndex--;\r\n return;\r\n }\r\n\r\n this.scrollToOption(currentItem as HTMLElement);\r\n }\r\n\r\n @Watch('isOpen')\r\n async isOpenChanged() {\r\n // Base class의 이벤트 관리 호출 - 다른 select와의 이벤트 충돌 방지\r\n this.onDropdownToggle(this.isOpen);\r\n\r\n const selectedOption = this.getSelectedOption();\r\n if (!selectedOption) {\r\n this.itemIndex = -1;\r\n } else {\r\n this.itemIndex = this.options.indexOf(selectedOption[0]);\r\n }\r\n\r\n this.dropDownShow?.emit({ isOpen: this.isOpen });\r\n\r\n if (this.isOpen === false) return;\r\n\r\n await new Promise(resolve => setTimeout(resolve, 10));\r\n\r\n const optionElements = Array.from(\r\n this.dropdownRef?.querySelectorAll('.sd-select-multiple__dropdown sd-select-item') || [],\r\n );\r\n const currentItem = optionElements?.[this.itemIndex];\r\n\r\n // 드롭다운이 열릴 때 검색 입력에 포커스\r\n if (this.searchable) {\r\n const searchInput = await this.getNativeInputElement();\r\n searchInput?.focus();\r\n }\r\n\r\n if (!currentItem) return;\r\n\r\n await new Promise(resolve => setTimeout(resolve, 10)); // 추가 딜레이\r\n this.scrollToOption(currentItem as HTMLElement);\r\n }\r\n\r\n connectedCallback() {\r\n // props가 모두 설정된 후에 실행되므로 올바른 options 값을 가져올 수 있음\r\n this.filteredOptions = this.options;\r\n this.initializeEvent(); // global dropdown Manager에 등록 + 이벤트 핸들러 초기화\r\n }\r\n\r\n disconnectedCallback() {\r\n this.cleanupEvent(); // global dropdown Manager에서 제거 + 이벤트 정리\r\n }\r\n\r\n protected handleDocumentClick(event: Event): void {\r\n if (!this.selectRef?.contains(event.target as Node)) {\r\n this.isOpen = false;\r\n }\r\n }\r\n\r\n protected handleDocumentKeydown(keyboardEvent: KeyboardEvent): void {\r\n keyboardEvent.stopPropagation();\r\n const targetKey = ['ArrowDown', 'ArrowUp', 'Enter', 'Escape'];\r\n if (!targetKey.includes(keyboardEvent.key)) return;\r\n\r\n keyboardEvent.preventDefault();\r\n switch (keyboardEvent.key) {\r\n case 'ArrowDown':\r\n case 'ArrowUp':\r\n const keyboardNavigation = new SelectKeyboardNavigation(this.searchable, this.filteredOptions);\r\n const nextIndex = keyboardNavigation.getNextIndex(this.itemIndex, keyboardEvent.key);\r\n this.itemIndex = nextIndex;\r\n break;\r\n case 'Enter':\r\n const selectedOption = this.filteredOptions[this.itemIndex];\r\n if (selectedOption && !selectedOption.disabled) {\r\n this.handleOptionSelection(selectedOption);\r\n }\r\n break;\r\n case 'Escape':\r\n this.isOpen = false;\r\n break;\r\n }\r\n }\r\n\r\n // event handlers\r\n handleTriggerClick = (event: Event) => {\r\n event.stopPropagation();\r\n\r\n if (!this.disabled) {\r\n this.isOpen = !this.isOpen;\r\n this.dropDownShow?.emit({ isOpen: this.isOpen });\r\n }\r\n };\r\n\r\n handleOptionClick = (detail: { option: SelectOption; event: Event }) => {\r\n const { option, event } = detail;\r\n event.stopPropagation();\r\n\r\n this.handleOptionSelection(option);\r\n };\r\n\r\n private filterOptions() {\r\n if (!this.searchText || this.searchText.trim() === '') {\r\n // 검색어가 없으면 전체 옵션 표시\r\n this.filteredOptions = this.options;\r\n } else {\r\n // 검색어가 있으면 필터링\r\n this.filteredOptions = this.options.filter(option =>\r\n option.label.toLowerCase().includes(this.searchText!.toLowerCase()),\r\n );\r\n }\r\n }\r\n\r\n private getSelectedOption(): SelectOption[] {\r\n return this.options.filter(option => this.value?.includes(option));\r\n }\r\n\r\n private handleDropdownScroll = (event: Event) => {\r\n const target = event.target as HTMLElement;\r\n const scrollTop = target.scrollTop;\r\n\r\n // 스크롤이 조금이라도 되면 그림자 표시\r\n this.isScrolled = scrollTop > 0;\r\n };\r\n\r\n private async getNativeInputElement(): Promise<HTMLInputElement | null> {\r\n if (this.searchRef) {\r\n return this.searchRef.getNativeElement();\r\n }\r\n return null;\r\n }\r\n\r\n private handleOptionSelection = (option: SelectOption) => {\r\n if (!option || option.disabled) return;\r\n\r\n const isAlreadySelected = this.value?.some(opt => opt.value === option.value);\r\n if (isAlreadySelected) {\r\n // 이미 선택된 옵션인 경우, 선택 해제\r\n this.value = this.value?.filter(opt => opt.value !== option.value) || null;\r\n } else {\r\n // 새로운 옵션 선택\r\n this.value = [...(this.value || []), option];\r\n }\r\n };\r\n\r\n closeDropdown() {\r\n this.isOpen = false;\r\n }\r\n\r\n private scrollToOption(optionElement: HTMLElement) {\r\n if (!this.dropdownRef || !optionElement) return;\r\n\r\n const dropdown = this.dropdownRef;\r\n const optionTop = optionElement.offsetTop;\r\n const optionHeight = optionElement.offsetHeight;\r\n const dropdownScrollTop = dropdown.scrollTop;\r\n const dropdownHeight = dropdown.clientHeight;\r\n\r\n const searchContainer = dropdown.querySelector('.sd-select__search-container');\r\n const searchOffset = searchContainer ? (searchContainer as HTMLElement).offsetHeight : 0;\r\n\r\n const visibleTop = dropdownScrollTop + searchOffset;\r\n const visibleBottom = dropdownScrollTop + dropdownHeight;\r\n\r\n if (optionTop < visibleTop) {\r\n dropdown.scrollTop = optionTop - searchOffset;\r\n } else if (optionTop + optionHeight > visibleBottom) {\r\n dropdown.scrollTop = optionTop + optionHeight - dropdownHeight + searchOffset;\r\n }\r\n }\r\n\r\n // render method\r\n render() {\r\n const style = {\r\n '--select-width': this.width || '200px',\r\n '--select-dropdown-height': this.dropdownHeight || '260px',\r\n };\r\n\r\n return (\r\n <Host style={style}>\r\n <div\r\n class={{\r\n 'sd-select-multiple': true,\r\n 'sd-select-multiple--open': this.isOpen,\r\n 'sd-select-multiple--disabled': this.disabled,\r\n }}\r\n ref={el => (this.selectRef = el)}\r\n >\r\n {this.renderLabel(this.label)}\r\n <div class=\"sd-select-multiple__container\">\r\n {this.renderTrigger()}\r\n {this.renderDropdown()}\r\n </div>\r\n </div>\r\n </Host>\r\n );\r\n }\r\n\r\n private renderLabel(label?: string) {\r\n if (!label) return null;\r\n\r\n return <label class=\"sd-select-multiple__label\">{label}</label>;\r\n }\r\n\r\n private renderTrigger() {\r\n const selectedOption = this.getSelectedOption();\r\n return (\r\n <div\r\n class=\"sd-select-multiple__trigger\"\r\n tabindex={this.disabled ? -1 : 0}\r\n onClick={this.handleTriggerClick}\r\n >\r\n <span class=\"sd-select-multiple__value\">\r\n {!selectedOption\r\n ? '선택'\r\n : selectedOption.length\r\n ? selectedOption.map(option => option.label).join(', ')\r\n : this.placeholder}\r\n </span>\r\n {this.clearable && selectedOption?.length > 0 && !this.disabled && (\r\n <sd-icon\r\n key=\"close-icon\"\r\n name=\"close\"\r\n size={10}\r\n color=\"#888\"\r\n class=\"sd-select-multiple__clear\"\r\n onClick={event => {\r\n event.stopPropagation();\r\n this.value = null;\r\n }}\r\n ></sd-icon>\r\n )}\r\n\r\n <sd-icon\r\n key=\"arrow-icon\"\r\n name=\"arrowDown\"\r\n color=\"#888\"\r\n class={{ 'sd-select-multiple__arrow': true, 'sd-select-multiple__arrow--open': this.isOpen }}\r\n ></sd-icon>\r\n </div>\r\n );\r\n }\r\n\r\n private renderDropdown() {\r\n if (this.isOpen === false) return null;\r\n return (\r\n <sd-portal open={this.isOpen} parentRef={this.selectRef} onSdClose={this.closeDropdown}>\r\n <div\r\n class=\"sd-select-multiple__dropdown\"\r\n onScroll={this.handleDropdownScroll}\r\n ref={el => (this.dropdownRef = el)}\r\n >\r\n {this.searchable && (\r\n <div\r\n class={{\r\n 'sd-select-multiple__search-container': true,\r\n 'sd-select-multiple__search-container--scrolled': this.isScrolled,\r\n }}\r\n onClick={event => event.stopPropagation()}\r\n >\r\n <sd-input\r\n ref={el => (this.searchRef = el)}\r\n value={this.searchText}\r\n placeholder=\"검색\"\r\n clearable\r\n inputStyle={{ 'padding-left': '8px' }}\r\n autofocus\r\n onSdInput={event => {\r\n this.searchText = String(event?.detail);\r\n }}\r\n onSdFocus={() => {\r\n this.itemIndex = -1;\r\n }}\r\n >\r\n <sd-icon\r\n name=\"search\"\r\n size={16}\r\n color=\"#737373\"\r\n style={{ marginRight: '4px' }}\r\n slot=\"prefix\"\r\n ></sd-icon>\r\n </sd-input>\r\n </div>\r\n )}\r\n {this.filteredOptions.length > 0 ? (\r\n this.filteredOptions.map((option, index) => (\r\n <slot name={`option-${option.value}`}>\r\n <sd-select-option\r\n option={option}\r\n index={index}\r\n isSelected={this.value?.some(selected => selected.value === option.value)}\r\n isFocused={index === this.itemIndex}\r\n onOptionClick={({ detail }: { detail: { option: SelectOption; event: Event } }) =>\r\n this.handleOptionClick(detail)\r\n }\r\n useCheckbox={this.useCheckbox}\r\n ></sd-select-option>\r\n </slot>\r\n ))\r\n ) : (\r\n <slot name=\"option-placeholder\">\r\n <div class={'sd-select-multiple__option-placeholder'}>{this.optionPlaceholder}</div>\r\n </slot>\r\n )}\r\n </div>\r\n </sd-portal>\r\n );\r\n }\r\n}\r\n"]}
|